Struct futures_cpupool::CpuPool [] [src]

pub struct CpuPool {
    // some 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 the CpuPool 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 CpuPool implements Clone which just clones a new reference to the underlying thread pool.

Methods

impl CpuPool
[src]

fn new(size: u32) -> CpuPool

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.

fn execute<F, R>(&self, f: F) -> CpuFuture<R> where F: FnOnce() -> R + Send + 'static, R: Send + 'static

Execute some work on this thread pool, returning a future to the work that's running on the thread pool.

This function will execute the closure f on the associated thread pool, and return a future representing the finished computation. The future will either resolve to R if the computation finishes successfully or to Box<Any+Send> if it panics.

Trait Implementations

impl Clone for CpuPool
[src]

fn clone(&self) -> CpuPool

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

impl Drop for CpuPool
[src]

fn drop(&mut self)

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