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]

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()

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]

Spawns a future to run on this Spawn. Read more

impl Clone for ThreadPool
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Drop for ThreadPool
[src]

A method called when the value goes out of scope. Read more