Vendor things
This commit is contained in:
parent
5deceec006
commit
977e3c17e5
19434 changed files with 10682014 additions and 0 deletions
29
third-party/vendor/loom/tests/yield.rs
vendored
Normal file
29
third-party/vendor/loom/tests/yield.rs
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#![deny(warnings, rust_2018_idioms)]
|
||||
|
||||
use loom::sync::atomic::AtomicUsize;
|
||||
use loom::thread;
|
||||
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
fn yield_completes() {
|
||||
loom::model(|| {
|
||||
let inc = Arc::new(AtomicUsize::new(0));
|
||||
|
||||
{
|
||||
let inc = inc.clone();
|
||||
thread::spawn(move || {
|
||||
inc.store(1, Relaxed);
|
||||
});
|
||||
}
|
||||
|
||||
loop {
|
||||
if 1 == inc.load(Relaxed) {
|
||||
return;
|
||||
}
|
||||
|
||||
loom::thread::yield_now();
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue