Struct scoped_pool::Pool
[−]
[src]
pub struct Pool {
// some fields omitted
}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]
fn new(size: usize) -> Pool
Create a new Pool with size threads.
If size is zero, no threads will be spawned. Threads can
be added later via expand.
fn empty() -> Pool
Create an empty Pool, with no threads.
Note that no jobs will run until expand is called and
worker threads are added.
fn spawn<F: FnOnce() + Send + 'static>(&self, job: F)
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.
fn scoped<'scope, F, R>(&self, scheduler: F) -> R where 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.
fn shutdown(&self)
Shutdown the Pool.
WARNING: Extreme care should be taken to not call shutdown concurrently with any scoped calls, or deadlock can occur.
Only guaranteed to shut down all threads started before the call to shutdown,
threads started concurrently or after the call to shutdown (using expand) may
or may not be shut down.
fn expand(&self)
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
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more