| 1348 | counter.fetch_add(1, Ordering::Relaxed); |
| 1349 | }); |
| 1350 | }); |
| 1351 | scope.spawn(|_: &Worker| { |
| 1352 | counter.fetch_add(1, Ordering::Relaxed); |
| 1353 | scope.spawn(|_: &Worker| { |
| 1354 | counter.fetch_add(1, Ordering::Relaxed); |
| 1355 | }); |
| 1356 | }); |
| 1357 | }); |
| 1358 | assert_eq!(counter.load(Ordering::Relaxed), 4); |
| 1359 | |
| 1360 | THREAD_POOL.depopulate(); |
| 1361 | } |
| 1362 | |
| 1363 | /// Tests that we can spawn futures onto the thread pool and that they can |
| 1364 | /// borrow data as expected. |
| 1365 | #[test] |
| 1366 | fn scope_future() { |
| 1367 | static THREAD_POOL: ThreadPool = ThreadPool::new(); |
| 1368 | THREAD_POOL.resize_to_available(); |
| 1369 | |
| 1370 | let mut value = 0; |
| 1371 | THREAD_POOL.scope(|scope| { |