xref: /drstd/src/std/sys/sgx/waitqueue/tests.rs (revision 86982c5e9b2eaa583327251616ee822c36288824)
1 use super::*;
2 use crate::std::sync::Arc;
3 use crate::std::thread;
4 
5 #[test]
6 fn queue() {
7     let wq = Arc::new(SpinMutex::<WaitVariable<()>>::default());
8     let wq2 = wq.clone();
9 
10     let locked = wq.lock();
11 
12     let t1 = thread::spawn(move || {
13         // if we obtain the lock, the main thread should be waiting
14         assert!(WaitQueue::notify_one(wq2.lock()).is_ok());
15     });
16 
17     WaitQueue::wait(locked, || {});
18 
19     t1.join().unwrap();
20 }
21