MCPcopy Create free account
hub / github.com/SSheldon/rust-dispatch / test_barrier_async

Function test_barrier_async

src/queue.rs:466–486  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

464
465 #[test]
466 fn test_barrier_async() {
467 let q = Queue::create("", QueueAttribute::Concurrent);
468 let num = Arc::new(Mutex::new(0));
469
470 async_increment(&q, &num);
471 async_increment(&q, &num);
472
473 let num2 = num.clone();
474 q.barrier_async(move || {
475 let mut num = num2.lock().unwrap();
476 if *num == 2 {
477 *num = 10;
478 }
479 });
480
481 async_increment(&q, &num);
482 async_increment(&q, &num);
483
484 q.barrier_sync(|| ());
485 assert_eq!(*num.lock().unwrap(), 12);
486 }
487
488 #[test]
489 fn test_suspend() {

Callers

nothing calls this directly

Calls 4

barrier_asyncMethod · 0.80
barrier_syncMethod · 0.80
async_incrementFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected