()
| 1203 | }); |
| 1204 | scope.spawn(|_: &Worker| { |
| 1205 | counter.fetch_add(1, Ordering::Relaxed); |
| 1206 | scope.spawn(|_: &Worker| { |
| 1207 | counter.fetch_add(1, Ordering::Relaxed); |
| 1208 | }); |
| 1209 | }); |
| 1210 | }); |
| 1211 | assert_eq!(counter.load(Ordering::Relaxed), 4); |
| 1212 | |
| 1213 | THREAD_POOL.depopulate(); |
| 1214 | } |
| 1215 | |
| 1216 | /// Tests that we can spawn futures onto the thread pool and that they can |
| 1217 | /// borrow data as expected. |
| 1218 | #[test] |
| 1219 | fn scope_future() { |
| 1220 | static THREAD_POOL: ThreadPool = ThreadPool::new(); |
| 1221 | THREAD_POOL.resize_to_available(); |
| 1222 | |
| 1223 | let mut value = 0; |
| 1224 | THREAD_POOL.scope(|scope| { |
| 1225 | scope.spawn(async { |
| 1226 | value = 42; |
| 1227 | }); |
nothing calls this directly
no test coverage detected