Skip to main content

RuntimeFactory

Trait RuntimeFactory 

Source
pub trait RuntimeFactory: Runtime {
    type Mutex<T: Send + 'static>: MutexLike<T>;
    type Notify: NotifyLike;
    type JoinSet<T: Send + 'static>: JoinSetLike<T>;
    type Sleep: Future<Output = ()> + Send;

    // Required methods
    fn new_mutex<T: Send + 'static>(value: T) -> Self::Mutex<T>;
    fn new_notify() -> Self::Notify;
    fn new_join_set<T: Send + 'static>() -> Self::JoinSet<T>;
    fn sleep(duration: Duration) -> Self::Sleep;
}
Expand description

Sibling extension of Runtime: typed factory methods for the per-session sync / task / time primitives. Implemented by every concrete runtime that ships in the workspace (TokioPerCoreRuntime, PrimeRuntime). Consumers bound on R: RuntimeFactory when they need typed primitives; consumers that only need to spawn stay on R: Runtime and the trait stays dyn-compatible.

Required Associated Types§

Source

type Mutex<T: Send + 'static>: MutexLike<T>

Source

type Notify: NotifyLike

Source

type JoinSet<T: Send + 'static>: JoinSetLike<T>

Source

type Sleep: Future<Output = ()> + Send

Send because the awaiter may move across thread boundaries on tokio’s multi-thread runtime.

Required Methods§

Source

fn new_mutex<T: Send + 'static>(value: T) -> Self::Mutex<T>

Source

fn new_notify() -> Self::Notify

Source

fn new_join_set<T: Send + 'static>() -> Self::JoinSet<T>

Source

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

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§