Trait crossbus::rt::Spawning

source ·
pub trait Spawning<T, H, U> {
    // Required methods
    fn spawn<F>(fut: F) -> H
       where F: CoreFuture<Output = T> + Send + 'static,
             T: Send + 'static,
             H: SpawnJoinHandle<U>;
    fn spawn_blocking<F>(fut: F) -> H
       where F: FnOnce() -> T + Send + 'static,
             T: Send + 'static,
             H: SpawnJoinHandle<U>;
    fn block_on<F>(fut: F) -> T
       where F: CoreFuture<Output = T>;
    fn spawn_local<F>(fut: F) -> H
       where F: CoreFuture<Output = T> + 'static,
             T: 'static,
             H: SpawnJoinHandle<U>;
}
Available on crate feature rt only.
Expand description

An abstraction for Actor’s Runtime routine

NOTE that not all methods need to be implemented it is okay to implement what you need to use and leave rest methods unimplemented, check the implementation of wasm runtime for example.

Required Methods§

source

fn spawn<F>(fut: F) -> Hwhere F: CoreFuture<Output = T> + Send + 'static, T: Send + 'static, H: SpawnJoinHandle<U>,

source

fn spawn_blocking<F>(fut: F) -> Hwhere F: FnOnce() -> T + Send + 'static, T: Send + 'static, H: SpawnJoinHandle<U>,

source

fn block_on<F>(fut: F) -> Twhere F: CoreFuture<Output = T>,

source

fn spawn_local<F>(fut: F) -> Hwhere F: CoreFuture<Output = T> + 'static, T: 'static, H: SpawnJoinHandle<U>,

Implementors§

source§

impl Spawning<(), Ready<()>, ()> for crossbus::rt::runtime_wasm32::Runtime

Available on crate feature wasm32 only.
source§

impl<T> Spawning<T, JoinHandle<T>, Result<T, JoinError>> for crossbus::rt::runtime_tokio::Runtime

Available on crate feature tokio only.
source§

impl<T> Spawning<T, JoinHandle<T>, T> for crossbus::rt::runtime_async_std::Runtime

Available on crate feature async-std only.

async-std has a global runtime each time a future is spawned the global runtime is used