[−][src]Struct scoped_pool::Pool
A thread-pool providing scoped and unscoped threads.
The primary ways of interacting with the Pool are
the spawn and scoped convenience methods or through
the Scope type directly.
Methods
impl Pool[src]
pub fn new(size: usize) -> Pool[src]
Create a new Pool with size threads.
If size is zero, no threads will be spawned. Threads can
be added later via expand.
NOTE: Since Pool can be freely cloned, it does not represent a unique
handle to the thread pool. As a consequence, the thread pool is not
automatically shut down; you must explicitly call Pool::shutdown to
shut down the pool.
pub fn with_thread_config(size: usize, thread_config: ThreadConfig) -> Pool[src]
Create a new Pool with size threads and given thread config.
If size is zero, no threads will be spawned. Threads can
be added later via expand.
NOTE: Since Pool can be freely cloned, it does not represent a unique
handle to the thread pool. As a consequence, the thread pool is not
automatically shut down; you must explicitly call Pool::shutdown to
shut down the pool.
pub fn empty() -> Pool[src]
Create an empty Pool, with no threads.
Note that no jobs will run until expand is called and
worker threads are added.
pub fn workers(&self) -> usize[src]
How many worker threads are currently active.
pub fn spawn<F: FnOnce() + Send + 'static>(&self, job: F)[src]
Spawn a 'static' job to be run on this pool.
We do not wait on the job to complete.
Panics in the job will propogate to the calling thread.
pub fn scoped<'scope, F, R>(&self, scheduler: F) -> R where
F: FnOnce(&Scope<'scope>) -> R, [src]
F: FnOnce(&Scope<'scope>) -> R,
Create a Scope for scheduling a group of jobs in 'scope'.
scoped will return only when the scheduler function and
all jobs queued on the given Scope have been run.
Panics in any of the jobs or in the scheduler function itself will propogate to the calling thread.
pub fn shutdown(&self)[src]
Shutdown the Pool.
WARNING: Extreme care should be taken to not call shutdown concurrently with any scoped calls, or deadlock can occur.
All threads will be shut down eventually, but only threads started before the call to shutdown are guaranteed to be shut down before the call to shutdown returns.
pub fn expand(&self)[src]
Expand the Pool by spawning an additional thread.
Can accelerate the completion of running jobs.
Trait Implementations
impl Clone for Pool[src]
fn clone(&self) -> Pool[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Default for Pool[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,