MCPcopy Index your code
hub / github.com/SSheldon/rust-dispatch / test_suspend

Function test_suspend

src/queue.rs:489–505  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

487
488 #[test]
489 fn test_suspend() {
490 let q = Queue::create("", QueueAttribute::Serial);
491 let num = Arc::new(Mutex::new(0));
492
493 // Suspend the queue and then dispatch some work to it
494 let guard = q.suspend();
495 async_increment(&q, &num);
496
497 // Sleep and ensure the work doesn't occur
498 ::std::thread::sleep(Duration::from_millis(5));
499 assert_eq!(*num.lock().unwrap(), 0);
500
501 // But ensure the work does complete after we resume
502 guard.resume();
503 q.exec_sync(|| ());
504 assert_eq!(*num.lock().unwrap(), 1);
505 }
506}

Callers

nothing calls this directly

Calls 4

suspendMethod · 0.80
resumeMethod · 0.80
exec_syncMethod · 0.80
async_incrementFunction · 0.70

Tested by

no test coverage detected