| 800 | unsafe { storage.release() }; |
| 801 | // Panics may not unwind out of the job, so are sent to the thread pool's |
| 802 | // handler. |
| 803 | if let Err(payload) = result { |
| 804 | worker.thread_pool.handle_panic(payload); |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | // ----------------------------------------------------------------------------- |
| 809 | // Broadcasts |
| 810 | |
| 811 | /// Context object for [`broadcast`](Worker::broadcast) operations. |
| 812 | pub struct Broadcast<'w> { |
| 813 | /// The worker this part of the broadcast is running on. This will be in |
| 814 | /// `[0, participants)`. |
| 815 | pub worker: &'w Worker, |
| 816 | /// The index of this worker within the broadcast. The return value will be |
| 817 | /// stored at this index within the results vector. |
| 818 | pub index: usize, |
| 819 | /// The number of threads participating in the broadcast. |
| 820 | pub participants: usize, |
| 821 | } |
| 822 | |
| 823 | // ----------------------------------------------------------------------------- |
| 824 | // Thread pool operations |
| 825 | |
| 826 | impl ThreadPool { |
| 827 | /// Spawns a job into the thread pool. |