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

Function test_after

src/queue.rs:386–405  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

384
385 #[test]
386 fn test_after() {
387 let q = Queue::create("", QueueAttribute::Serial);
388 let group = Group::create();
389 let num = Arc::new(Mutex::new(0));
390
391 let delay = Duration::from_millis(5);
392 let num2 = num.clone();
393 let guard = group.enter();
394 let start = Instant::now();
395 q.exec_after(delay, move || {
396 let mut num = num2.lock().unwrap();
397 *num = 1;
398 guard.leave();
399 });
400
401 // Wait for the previous block to complete
402 group.wait_timeout(Duration::from_millis(5000)).unwrap();
403 assert!(start.elapsed() >= delay);
404 assert_eq!(*num.lock().unwrap(), 1);
405 }
406
407 #[test]
408 fn test_queue_label() {

Callers

nothing calls this directly

Calls 5

enterMethod · 0.80
exec_afterMethod · 0.80
leaveMethod · 0.80
cloneMethod · 0.45
wait_timeoutMethod · 0.45

Tested by

no test coverage detected