1 use crate::runtime::park;
2 use crate::runtime::tests::loom_oneshot as oneshot;
3 use crate::runtime::{self, Runtime};
4 
5 #[test]
6 #[ignore]
yield_calls_park_before_scheduling_again()7 fn yield_calls_park_before_scheduling_again() {
8     // Don't need to check all permutations
9     let mut loom = loom::model::Builder::default();
10     loom.max_permutations = Some(1);
11     loom.check(|| {
12         let rt = mk_runtime(2);
13         let (tx, rx) = oneshot::channel::<()>();
14 
15         rt.spawn(async {
16             let tid = loom::thread::current().id();
17             let park_count = park::current_thread_park_count();
18 
19             crate::task::yield_now().await;
20 
21             if tid == loom::thread::current().id() {
22                 let new_park_count = park::current_thread_park_count();
23                 assert_eq!(park_count + 1, new_park_count);
24             }
25 
26             tx.send(());
27         });
28 
29         rx.recv();
30     });
31 }
32 
mk_runtime(num_threads: usize) -> Runtime33 fn mk_runtime(num_threads: usize) -> Runtime {
34     runtime::Builder::new_multi_thread()
35         .worker_threads(num_threads)
36         .build()
37         .unwrap()
38 }
39