Type Alias Executor

Source
pub type Executor = ThreadPool;
Available on non-WebAssembly and crate feature thread-pool only.
Expand description

A thread pool executor for futures.

Aliased Type§

pub struct Executor { /* private fields */ }

Implementations

§

impl ThreadPool

pub fn new() -> Result<ThreadPool, Error>

Creates a new thread pool with the default configuration.

See documentation for the methods in ThreadPoolBuilder for details on the default configuration.

pub fn builder() -> ThreadPoolBuilder

Create a default thread pool configuration, which can then be customized.

See documentation for the methods in ThreadPoolBuilder for details on the default configuration.

pub fn spawn_obj_ok(&self, future: FutureObj<'static, ()>)

Spawns a future that will be run to completion.

Note: This method is similar to Spawn::spawn_obj, except that it is guaranteed to always succeed.

pub fn spawn_ok<Fut>(&self, future: Fut)
where Fut: Future<Output = ()> + Send + 'static,

Spawns a task that polls the given future with output () to completion.

use futures::executor::ThreadPool;

let pool = ThreadPool::new().unwrap();

let future = async { /* ... */ };
pool.spawn_ok(future);

Note: This method is similar to SpawnExt::spawn, except that it is guaranteed to always succeed.

Trait Implementations§

Source§

impl Executor for Executor

Source§

fn new() -> Result<Self, Error>

Creates a new Executor.
Source§

fn spawn(&self, future: impl Future<Output = ()> + Send + 'static)

Spawns a future in the Executor.
Source§

fn block_on<T>(&self, future: impl Future<Output = T>) -> T

Runs a future to completion in the current thread within the Executor.
Source§

fn enter<R>(&self, f: impl FnOnce() -> R) -> R

Runs the given closure inside the Executor. Read more
§

impl Clone for ThreadPool

§

fn clone(&self) -> ThreadPool

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for ThreadPool

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Drop for ThreadPool

§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

impl Spawn for ThreadPool

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

Spawns a future that will be run to completion. Read more
§

fn status(&self) -> Result<(), SpawnError>

Determines whether the executor is able to spawn new tasks. Read more