TaskRunnerImpl

Trait TaskRunnerImpl 

Source
pub trait TaskRunnerImpl: Debug + 'static {
    type Task<T: Send + 'static>: Task<T>;
    type LocalTask<T: 'static>: LocalTask<T>;

    // Required methods
    fn spawn<Fut>(&self, future: Fut) -> Self::Task<Fut::Output>
       where Fut: Future + Send + 'static,
             Fut::Output: Send + 'static;
    fn spawn_blocking<R, F>(&self, func: F) -> Self::Task<R>
       where R: Send + 'static,
             F: FnOnce() -> R + Send + 'static;
    fn block_on<Fut>(&self, future: Fut) -> Fut::Output
       where Fut: Future;
}
Expand description

A trait that provides a task runner implementation.

Required Associated Types§

Source

type Task<T: Send + 'static>: Task<T>

The task type, that this task runner implementation uses.

Source

type LocalTask<T: 'static>: LocalTask<T>

The local task type, that this task runner implementation uses.

Required Methods§

Source

fn spawn<Fut>(&self, future: Fut) -> Self::Task<Fut::Output>
where Fut: Future + Send + 'static, Fut::Output: Send + 'static,

Spawns a task, possibly in the background.

Returns a task handle to the future.

Source

fn spawn_blocking<R, F>(&self, func: F) -> Self::Task<R>
where R: Send + 'static, F: FnOnce() -> R + Send + 'static,

Spawns a blocking task in the background.

Returns a task handle to the operation.

Source

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

Blocks on the given future, until it’s completed.

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§