Struct futures_threadpool::ThreadPool
[−]
[src]
pub struct ThreadPool { /* fields omitted */ }
A thread pool intended to run CPU intensive work.
This thread pool will hand out futures representing the completed work that happens on the thread pool itself, and the futures can then be later composed with other work as part of an overall computation.
The worker threads associated with a thread pool are kept alive so long as
there is an open handle to the ThreadPool
or there is work running on them. Once
all work has been drained and all references have gone away the worker
threads will be shut down.
Currently ThreadPool
implements Clone
which just clones a new reference to
the underlying thread pool.
Note: if you use ThreadPool inside a library it's better accept a
Builder
object for thread configuration rather than configuring just
pool size. This not only future proof for other settings but also allows
user to attach monitoring tools to lifecycle hooks.
Methods
impl ThreadPool
[src]
fn new(size: usize) -> ThreadPool
Creates a new thread pool with size
worker threads associated with it.
The returned handle can use execute
to run work on this thread pool,
and clones can be made of it to get multiple references to the same
thread pool.
This is a shortcut for:
rust Builder::new().pool_size(size).create()
fn new_num_cpus() -> ThreadPool
Creates a new thread pool with a number of workers equal to the number of CPUs on the host.
This is a shortcut for:
rust Builder::new().create()
Trait Implementations
impl<T> Spawn<T> for ThreadPool where
T: Future<Item = (), Error = ()> + Send + 'static,
[src]
T: Future<Item = (), Error = ()> + Send + 'static,
fn spawn_detached(&self, f: T)
Spawns a future to run on this Spawn
. Read more
impl Clone for ThreadPool
[src]
fn clone(&self) -> ThreadPool
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