Skip to main content

ExecutorBlocking

Trait ExecutorBlocking 

Source
pub trait ExecutorBlocking: Executor {
    // Required method
    fn spawn_blocking<F, R>(&self, f: F) -> JoinHandle<R> 
       where F: FnOnce() -> R + Send + 'static,
             R: Send + 'static;
}

Required Methods§

Source

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

Spawn a thread in the background with the ability to concurrently await on the results without blocking the executor.

Note that there is no real way to abort the thread, and calling JoinHandle::abort would only abort the underlining tasked that is being polled but not the thread itself.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<E> ExecutorBlocking for Rc<E>

Source§

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

Source§

impl<E> ExecutorBlocking for Arc<E>

Source§

fn spawn_blocking<F, T>(&self, future: F) -> JoinHandle<T>
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,

Implementors§