Skip to main content

BraidRuntime

Trait BraidRuntime 

Source
pub trait BraidRuntime:
    Send
    + Sync
    + 'static {
    // Required methods
    fn spawn(&self, future: Pin<Box<dyn Future<Output = ()> + Send + 'static>>);
    fn sleep(
        &self,
        duration: Duration,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>;
    fn now_ms(&self) -> u64;
}
Expand description

Abstraction for asynchronous runtime operations.

Required Methods§

Source

fn spawn(&self, future: Pin<Box<dyn Future<Output = ()> + Send + 'static>>)

Spawn a background task.

Source

fn sleep( &self, duration: Duration, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>

Yield execution for a duration.

Source

fn now_ms(&self) -> u64

Get current Unix timestamp in milliseconds.

Implementors§

Source§

impl BraidRuntime for NativeRuntime

Available on crate feature native and non-WebAssembly only.