pub struct ThreadPool { /* private fields */ }Available on (crate features
rayon or default-thread-pool) and crate feature default-thread-pool only.Expand description
A thread pool that can execute parallel pipelines.
This type doesn’t expose any public methods other than
num_threads(). You can interact with it via
the ThreadPoolBuilder::build() function to create a thread pool, and the
with_thread_pool()
method to attach a thread pool to a parallel iterator.
Implementations§
Source§impl ThreadPool
impl ThreadPool
Sourcepub fn num_threads(&self) -> NonZeroUsize
pub fn num_threads(&self) -> NonZeroUsize
Returns the number of worker threads that have been spawned in this thread pool.
Trait Implementations§
Source§impl GenericThreadPool for &mut ThreadPool
impl GenericThreadPool for &mut ThreadPool
Source§fn upper_bounded_pipeline<Output: Send, Accum>(
self,
input_len: usize,
init: impl Fn() -> Accum + Sync,
process_item: impl Fn(Accum, usize) -> ControlFlow<Accum, Accum> + Sync,
finalize: impl Fn(Accum) -> Output + Sync,
reduce: impl Fn(Output, Output) -> Output,
cleanup: &(impl SourceCleanup + Sync),
) -> Output
fn upper_bounded_pipeline<Output: Send, Accum>( self, input_len: usize, init: impl Fn() -> Accum + Sync, process_item: impl Fn(Accum, usize) -> ControlFlow<Accum, Accum> + Sync, finalize: impl Fn(Accum) -> Output + Sync, reduce: impl Fn(Output, Output) -> Output, cleanup: &(impl SourceCleanup + Sync), ) -> Output
Processes an input of the given length in parallel and returns the
aggregated output. Read more
Source§fn iter_pipeline<Output, Accum: Send>(
self,
input_len: usize,
accum: impl Accumulator<usize, Accum> + Sync,
reduce: impl ExactSizeAccumulator<Accum, Output>,
cleanup: &(impl SourceCleanup + Sync),
) -> Output
fn iter_pipeline<Output, Accum: Send>( self, input_len: usize, accum: impl Accumulator<usize, Accum> + Sync, reduce: impl ExactSizeAccumulator<Accum, Output>, cleanup: &(impl SourceCleanup + Sync), ) -> Output
Processes an input of the given length in parallel and returns the
aggregated output. Read more
Auto Trait Implementations§
impl Freeze for ThreadPool
impl !RefUnwindSafe for ThreadPool
impl Send for ThreadPool
impl Sync for ThreadPool
impl Unpin for ThreadPool
impl !UnwindSafe for ThreadPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more