common_runtime::runtime

Trait RuntimeTrait

source
pub trait RuntimeTrait {
    // Required methods
    fn spawn<F>(&self, future: F) -> JoinHandle<F::Output> 
       where F: Future + Send + 'static,
             F::Output: Send + 'static;
    fn spawn_blocking<F, R>(&self, func: F) -> JoinHandle<R> 
       where F: FnOnce() -> R + Send + 'static,
             R: Send + 'static;
    fn block_on<F: Future>(&self, future: F) -> F::Output;
    fn name(&self) -> &str;

    // Provided method
    fn builder() -> Builder { ... }
}

Required Methods§

source

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

Spawn a future and execute it in this thread pool

Similar to tokio::runtime::Runtime::spawn()

source

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

Run the provided function on an executor dedicated to blocking operations.

source

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

Run a future to complete, this is the runtime’s entry point

source

fn name(&self) -> &str

Get the name of the runtime

Provided Methods§

source

fn builder() -> Builder

Get a runtime builder

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§