Skip to main content

RuntimeCompletion

Trait RuntimeCompletion 

Source
pub trait RuntimeCompletion: 'static {
    type Sleep: Future<Output = ()>;

    // Required methods
    fn sleep(duration: Duration) -> Self::Sleep;
    fn block_on<F: Future>(future: F) -> Result<F::Output, Error>;
}
Expand description

Base async scheduling — timer support for all runtimes.

This is the foundation for all runtimes. Every runtime (tokio, smol, compio, wasm) implements this trait. It provides only the sleep primitive; spawning is split into RuntimeLocal (completion-based) and RuntimePoll (work-stealing) to prevent runtime-inappropriate spawn calls from compiling.

Required Associated Types§

Source

type Sleep: Future<Output = ()>

A sleep future returned by the runtime.

Required Methods§

Source

fn sleep(duration: Duration) -> Self::Sleep

Sleep for the given duration.

Source

fn block_on<F: Future>(future: F) -> Result<F::Output, Error>

Run a future to completion on a new runtime instance.

Creates a single-threaded runtime and blocks the current thread until the future completes. Used by the blocking client wrapper.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§