Trait cfx_rpc_utils::helpers::blocking_tasks::SpawnBlocking
source · pub trait SpawnBlocking: Clone + Send + Sync + 'static {
// Required method
fn io_task_spawner(&self) -> impl TaskSpawner;
// Provided method
fn spawn_blocking_io<F, R>(
&self,
f: F
) -> impl Future<Output = Result<R, ErrorObjectOwned>> + Send
where F: FnOnce(Self) -> Result<R, ErrorObjectOwned> + Send + 'static,
R: Send + 'static { ... }
}
Expand description
Executes code on a blocking thread.
Required Methods§
sourcefn io_task_spawner(&self) -> impl TaskSpawner
fn io_task_spawner(&self) -> impl TaskSpawner
Returns a handle for spawning IO heavy blocking tasks.
Runtime access in default trait method implementations.
Provided Methods§
sourcefn spawn_blocking_io<F, R>(
&self,
f: F
) -> impl Future<Output = Result<R, ErrorObjectOwned>> + Send
fn spawn_blocking_io<F, R>( &self, f: F ) -> impl Future<Output = Result<R, ErrorObjectOwned>> + Send
Executes the future on a new blocking task.
Note: This is expected for futures that are dominated by blocking IO
operations, for tracing or CPU bound operations in general use
spawn_tracing
.
Object Safety§
This trait is not object safe.