Skip to main content

RuntimeDriver

Trait RuntimeDriver 

Source
pub trait RuntimeDriver: Clone + 'static {
    // Required methods
    fn now(&self) -> Duration;
    fn sleep_until(&self, deadline: Duration) -> LocalBoxFuture<'static, ()>;
    fn yield_now(&self) -> LocalBoxFuture<'static, ()>;
    fn spawn_local(&self, task: LocalTask) -> Result<DriverTask, SpawnError>;
    fn shutdown_requested(&self) -> bool;

    // Provided methods
    fn wait_for_runtime_event(
        &self,
        _deadline: Duration,
    ) -> LocalBoxFuture<'static, ()> { ... }
    fn jitter(&self, _maximum: Duration) -> Duration { ... }
}
Expand description

Host facilities required to advance the portable Kernel.

Required Methods§

Source

fn now(&self) -> Duration

Returns the current monotonic instant relative to Driver startup.

Source

fn sleep_until(&self, deadline: Duration) -> LocalBoxFuture<'static, ()>

Waits until the supplied monotonic instant.

Source

fn yield_now(&self) -> LocalBoxFuture<'static, ()>

Cooperatively yields to other work on the local task lane.

Source

fn spawn_local(&self, task: LocalTask) -> Result<DriverTask, SpawnError>

Schedules Kernel-owned work on the local task lane.

Source

fn shutdown_requested(&self) -> bool

Reports whether the embedding Runner requested shutdown.

Provided Methods§

Source

fn wait_for_runtime_event( &self, _deadline: Duration, ) -> LocalBoxFuture<'static, ()>

Waits for Runner control work or until the supplied monotonic instant.

Drivers with an event source should override this to park the lane. The yielding default preserves compatibility with deterministic and embedded Drivers that advance work cooperatively.

Source

fn jitter(&self, _maximum: Duration) -> Duration

Supplies deterministic or entropy-backed jitter bounded by the policy value.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§