| 1279 | #[test] |
| 1280 | fn scope_sleeping_future() { |
| 1281 | static THREAD_POOL: ThreadPool = ThreadPool::new(); |
| 1282 | THREAD_POOL.resize_to_available(); |
| 1283 | |
| 1284 | let mut complete = false; |
| 1285 | THREAD_POOL.scope(|scope| { |
| 1286 | scope.spawn(async { |
| 1287 | // Spawn a count future onto the thread pool, then have this |
| 1288 | // future sleep until that future is done. |
| 1289 | THREAD_POOL.spawn(CountFuture::default()).await; |
| 1290 | complete = true; |
| 1291 | }) |
| 1292 | }); |
| 1293 | |
| 1294 | assert!(complete); |
| 1295 | |
| 1296 | THREAD_POOL.depopulate(); |
| 1297 | } |
| 1298 | |
| 1299 | /// Tests that blocking functions like `join` can be nested within scopes. |
| 1300 | #[test] |