()
| 439 | |
| 440 | #[test] |
| 441 | fn test_barrier_sync() { |
| 442 | let q = Queue::create("", QueueAttribute::Concurrent); |
| 443 | let num = Arc::new(Mutex::new(0)); |
| 444 | |
| 445 | async_increment(&q, &num); |
| 446 | async_increment(&q, &num); |
| 447 | |
| 448 | let num2 = num.clone(); |
| 449 | let result = q.barrier_sync(move || { |
| 450 | let mut num = num2.lock().unwrap(); |
| 451 | if *num == 2 { |
| 452 | *num = 10; |
| 453 | } |
| 454 | *num |
| 455 | }); |
| 456 | assert_eq!(result, 10); |
| 457 | |
| 458 | async_increment(&q, &num); |
| 459 | async_increment(&q, &num); |
| 460 | |
| 461 | q.barrier_sync(|| ()); |
| 462 | assert_eq!(*num.lock().unwrap(), 12); |
| 463 | } |
| 464 | |
| 465 | #[test] |
| 466 | fn test_barrier_async() { |
nothing calls this directly
no test coverage detected