()
| 2584 | Worker::with_current(|worker| match worker { |
| 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 |
| 2604 | F: Future<Output = T> + Send, |
| 2605 | T: Send, |
| 2606 | { |
| 2607 | Worker::with_current(|worker| match worker { |
| 2608 | Some(worker) => worker.block_on(future), |
| 2609 | None => DEFAULT_POOL.block_on(future), |
| 2610 | }) |
| 2611 | } |
| 2612 | |
| 2613 | /// Executes the two closures, possibly in parallel. |
nothing calls this directly
no test coverage detected