Trait Executor

Source
pub trait Executor:
    Clone
    + Sync
    + Send
    + 'static {
    // Required methods
    fn spawn<F>(&self, future: F) -> impl JoinHandle<F::Output>
       where F: Future + Send + 'static,
             F::Output: Send;
    fn block_on<F: Future>(&self, future: F) -> F::Output;

    // Provided method
    fn run_until_ctrl_c(&self) { ... }
}

Required Methods§

Source

fn spawn<F>(&self, future: F) -> impl JoinHandle<F::Output>
where F: Future + Send + 'static, F::Output: Send,

spawns the task to run in background, and returns a join handle where the future’s result can be awaited. If the future panics, the join handle should return an error code. This is primarily used by mssf Bridge to execute user app async callbacks/notifications. User app impl future may panic, and mssf propagates panic as an error in JoinHandle to SF.

Source

fn block_on<F: Future>(&self, future: F) -> F::Output

run the future on the executor until completion.

Provided Methods§

Source

fn run_until_ctrl_c(&self)

Run the executor and block the current thread until ctrl-c event is Received.

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§