Trait AsyncRuntime

Source
pub trait AsyncRuntime {
    type YieldNowFuture: Future<Output = ()>;

    // Required method
    fn yield_now(&self) -> Self::YieldNowFuture;
}
Expand description

Async runtime abstraction

Abstracts async runtime like tokio. Currently only exposes a yield_now function.

Required Associated Types§

Source

type YieldNowFuture: Future<Output = ()>

Future type returned by yield_now

Required Methods§

Source

fn yield_now(&self) -> Self::YieldNowFuture

Yields the execution back to the runtime

If the protocol performs a long computation, it might be better for performance to split it with yield points, so the signle computation does not starve other tasks.

Implementors§

Source§

impl AsyncRuntime for TokioRuntime

Available on crate feature runtime-tokio only.
Source§

type YieldNowFuture = Pin<Box<dyn Future<Output = ()> + Send>>

Source§

impl AsyncRuntime for UnknownRuntime

Source§

impl<M> AsyncRuntime for Runtime<M>

Available on crate feature state-machine only.