pub struct ThreadPool { /* private fields */ }Expand description
Thread pool with advanced features
Implementations§
Source§impl ThreadPool
impl ThreadPool
Sourcepub fn new(
num_threads: usize,
config: &WorkStealingConfig,
) -> IntegrateResult<Self>
pub fn new( num_threads: usize, config: &WorkStealingConfig, ) -> IntegrateResult<Self>
Create new thread pool
Sourcepub fn execute_tasks(
&self,
tasks: Vec<Box<dyn ParallelTask + Send>>,
) -> IntegrateResult<Vec<ParallelResult>>
pub fn execute_tasks( &self, tasks: Vec<Box<dyn ParallelTask + Send>>, ) -> IntegrateResult<Vec<ParallelResult>>
Execute tasks in parallel and collect their real results.
Large tasks are subdivided (when can_subdivide() and the estimated
cost warrants it) and the resulting work items are sorted largest-first
for better load balancing before being dispatched across the available
CPU threads via the data-parallel runtime. Each returned
ParallelResult is the genuine output of ParallelTask::execute;
there is one entry per executed (sub)task, in dispatch order.
Sourcepub fn shutdown(&mut self) -> IntegrateResult<()>
pub fn shutdown(&mut self) -> IntegrateResult<()>
Shutdown the thread pool and wait for all threads to complete
Trait Implementations§
Source§impl Drop for ThreadPool
impl Drop for ThreadPool
Auto Trait Implementations§
impl !RefUnwindSafe for ThreadPool
impl !UnwindSafe for ThreadPool
impl Freeze for ThreadPool
impl Send for ThreadPool
impl Sync for ThreadPool
impl Unpin for ThreadPool
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more