| 2585 | Some(worker) => worker.spawn_on(member_index, work), |
| 2586 | None => DEFAULT_POOL.spawn_on(member_index, work), |
| 2587 | }) |
| 2588 | } |
| 2589 | |
| 2590 | /// Waits for a future to complete. |
| 2591 | /// |
| 2592 | /// When executed on a thread that is currently registered as a worker (i.e. the |
| 2593 | /// closure inside [`Membership::activate`], [`ThreadPool::with_worker`], or |
| 2594 | /// similar) this is able to look up that registration and find the worker and |
| 2595 | /// thread-pool implicitly. |
| 2596 | /// |
| 2597 | /// If not called within a thread pool, this uses the [`DEFAULT_POOL`]. |
| 2598 | /// |
| 2599 | /// If you have a reference to a [`Worker`], it's better to use |
| 2600 | /// [`Worker::block_on`] instead. If you don't have a worker, but know which |
| 2601 | /// thread pool you want to use, [`ThreadPool::block_on`] is more appropriate. |
| 2602 | pub fn block_on<F, T>(future: F) -> T |
| 2603 | where |