SpawnBlocking

Trait SpawnBlocking 

Source
pub trait SpawnBlocking {
    // Required methods
    fn spawn_blocking<'a, R>(
        &mut self,
        task: impl FnOnce() -> R + Send + 'static,
    ) -> BoxFuture<'a, Result<R, Box<dyn Error + Send + Sync + 'static>>>
       where R: Send + 'static;
    fn get_runtime() -> Self;
}
Available on crate feature sync-connection-wrapper only.
Expand description

This is a helper trait that allows to customize the spawning blocking tasks as part of the SyncConnectionWrapper type. By default a tokio runtime and its spawn_blocking function is used.

Required Methods§

Source

fn spawn_blocking<'a, R>( &mut self, task: impl FnOnce() -> R + Send + 'static, ) -> BoxFuture<'a, Result<R, Box<dyn Error + Send + Sync + 'static>>>
where R: Send + 'static,

This function should allow to execute a given blocking task without blocking the caller to get the result

Source

fn get_runtime() -> Self

This function should be used to construct a new runtime instance

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.

Implementors§