Trait async_executors::iface::SpawnBlocking [−][src]
pub trait SpawnBlocking<R> where
R: Send + 'static, {
fn spawn_blocking<F>(&self, f: F) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
Self: Sized;
fn spawn_blocking_dyn(
&self,
f: Box<dyn FnOnce() -> R + Send>
) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
;
}
Expand description
Indicate the executor can provide a threadpool for blocking operations. There is two methods of this trait. One of them requires boxing the closure and the other is not object safe.
Required methods
fn spawn_blocking<F>(&self, f: F) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
Self: Sized,
fn spawn_blocking<F>(&self, f: F) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
Self: Sized,
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;
Runs the provided closure on a thread where blocking is acceptable.
fn spawn_blocking_dyn(
&self,
f: Box<dyn FnOnce() -> R + Send>
) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
fn spawn_blocking_dyn(
&self,
f: Box<dyn FnOnce() -> R + Send>
) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;
Runs the provided closure on a thread where blocking is acceptable. This part of the trait is object safe but your closure must be boxed and you cannot have a return value.
Implementations on Foreign Types
fn spawn_blocking<F>(&self, f: F) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
where
F: FnOnce() -> R + Send + 'static,
T: Sized,
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;
fn spawn_blocking_dyn(
&self,
f: Box<dyn FnOnce() -> R + Send>
) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;
impl<R, T: SpawnBlocking<R>> SpawnBlocking<R> for &mut T where
T: SpawnBlocking<R>,
R: Send + 'static,
impl<R, T: SpawnBlocking<R>> SpawnBlocking<R> for &mut T where
T: SpawnBlocking<R>,
R: Send + 'static,
fn spawn_blocking<F>(&self, f: F) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
where
F: FnOnce() -> R + Send + 'static,
T: Sized,
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;
fn spawn_blocking_dyn(
&self,
f: Box<dyn FnOnce() -> R + Send>
) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;
impl<R, T: SpawnBlocking<R>> SpawnBlocking<R> for Box<T> where
T: SpawnBlocking<R>,
R: Send + 'static,
impl<R, T: SpawnBlocking<R>> SpawnBlocking<R> for Box<T> where
T: SpawnBlocking<R>,
R: Send + 'static,
fn spawn_blocking<F>(&self, f: F) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
where
F: FnOnce() -> R + Send + 'static,
T: Sized,
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;
fn spawn_blocking_dyn(
&self,
f: Box<dyn FnOnce() -> R + Send>
) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;
impl<R, T: SpawnBlocking<R>> SpawnBlocking<R> for Arc<T> where
T: SpawnBlocking<R>,
R: Send + 'static,
impl<R, T: SpawnBlocking<R>> SpawnBlocking<R> for Arc<T> where
T: SpawnBlocking<R>,
R: Send + 'static,
fn spawn_blocking<F>(&self, f: F) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
where
F: FnOnce() -> R + Send + 'static,
T: Sized,
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;
fn spawn_blocking_dyn(
&self,
f: Box<dyn FnOnce() -> R + Send>
) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;
impl<R, T: SpawnBlocking<R>> SpawnBlocking<R> for Rc<T> where
T: SpawnBlocking<R>,
R: Send + 'static,
impl<R, T: SpawnBlocking<R>> SpawnBlocking<R> for Rc<T> where
T: SpawnBlocking<R>,
R: Send + 'static,
fn spawn_blocking<F>(&self, f: F) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
where
F: FnOnce() -> R + Send + 'static,
T: Sized,
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;
fn spawn_blocking_dyn(
&self,
f: Box<dyn FnOnce() -> R + Send>
) -> BlockingHandle<R>ⓘNotable traits for BlockingHandle<T>impl<T: 'static> Future for BlockingHandle<T> type Output = T;
Notable traits for BlockingHandle<T>
impl<T: 'static> Future for BlockingHandle<T> type Output = T;