-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track which reference belongs to with store
Add a unique id to stores, and keep track of this id in references. When a reference is used with a different store, this will panic with a message explaining that the user might be trying to reuse object across executions.
- Loading branch information
1 parent
f15f931
commit f0467b1
Showing
3 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![deny(warnings, rust_2018_idioms)] | ||
|
||
use loom::cell::Cell; | ||
|
||
thread_local! { | ||
static ACTIVE_FRAME: Cell<()> = Cell::new(()); | ||
} | ||
|
||
#[test] | ||
#[should_panic = "Tried to access an object using a reference that belongs to a different store. This might indicate you are trying to reuse an object from an earlier execution"] | ||
fn test_cell_reuse() { | ||
loom::model(|| { | ||
let handle_a = loom::thread::spawn(|| { | ||
let _ = ACTIVE_FRAME.with(Cell::get); | ||
}); | ||
let handle_b = loom::thread::spawn(|| ()); | ||
handle_a.join().unwrap(); | ||
handle_b.join().unwrap(); | ||
}); | ||
} |