Skip to main content

BlockingExecutor

Trait BlockingExecutor 

Source
pub trait BlockingExecutor:
    Send
    + Sync
    + 'static {
    // Required method
    fn execute(&self, work: Box<dyn FnOnce() + Send + 'static>);
}
Available on crate feature async only.
Expand description

Somewhere to run blocking work from an async context.

Implement this to hand the crate your runtime’s blocking pool. Without one it spawns a thread per call, which is correct everywhere and cheap enough for work that happens at startup and on reload.

Required Methods§

Source

fn execute(&self, work: Box<dyn FnOnce() + Send + 'static>)

Runs work somewhere it is allowed to block.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§