| 1348 | THREAD_POOL.depopulate(); |
| 1349 | } |
| 1350 | |
| 1351 | /// Tests that nesting two scopes on different workers will not deadlock. |
| 1352 | #[test] |
| 1353 | fn scope_nesting_new_worker() { |
| 1354 | static THREAD_POOL: ThreadPool = ThreadPool::new(); |
| 1355 | THREAD_POOL.resize_to_available(); |
| 1356 | |
| 1357 | let mut completed = false; |
| 1358 | |
| 1359 | THREAD_POOL.with_worker(|worker| { |
| 1360 | worker.scope(|scope| { |
| 1361 | scope.spawn(|_: &Worker| { |
| 1362 | // Creating a new worker instead of reusing the old one is |
| 1363 | // bad form, but we may as well test it. |
| 1364 | THREAD_POOL.with_worker(|worker| { |
| 1365 | worker.scope(|scope| { |
| 1366 | scope.spawn(|_: &Worker| { |
| 1367 | completed = true; |
| 1368 | }); |
| 1369 | }); |
| 1370 | }); |
| 1371 | }); |