pub struct Runtime(/* private fields */);Expand description
A type-erased RuntimeTrait implementation. Think of this as an Arc<dyn RuntimeTrait>
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new(runtime: impl RuntimeTrait) -> Self
pub fn new(runtime: impl RuntimeTrait) -> Self
Construct a new type-erased runtime object from any RuntimeTrait implementation.
Sourcepub fn spawn<Output: Send + 'static>(
&self,
fut: impl Future<Output = Output> + Send + 'static,
) -> DroppableFuture<Pin<Box<dyn Future<Output = Option<Output>> + Send + 'static>>> ⓘ
pub fn spawn<Output: Send + 'static>( &self, fut: impl Future<Output = Output> + Send + 'static, ) -> DroppableFuture<Pin<Box<dyn Future<Output = Option<Output>> + Send + 'static>>> ⓘ
Spawn a future on the runtime, returning a future that has detach-on-drop semantics
Spawned tasks conform to the following behavior:
-
detach on drop: If the returned
DroppableFutureis dropped immediately, the task will continue to execute until completion. -
unwinding: If the spawned future panics, this must not propagate to the join handle. Instead, the awaiting the join handle returns None in case of panic.
Sourcepub fn spawn_detached<Fut>(&self, fut: Fut)
pub fn spawn_detached<Fut>(&self, fut: Fut)
Spawn a future on the runtime without a join handle.
Cheaper than spawn when the caller doesn’t need the output or
completion signal: no channel or join-handle allocation is made.
Sourcepub fn interval(&self, period: Duration) -> impl Stream<Item = ()> + Send + '_
pub fn interval(&self, period: Duration) -> impl Stream<Item = ()> + Send + '_
Returns a Stream that yields a () on the provided period
Trait Implementations§
Source§impl RuntimeTrait for Runtime
impl RuntimeTrait for Runtime
Source§fn interval(&self, period: Duration) -> impl Stream<Item = ()> + Send + 'static
fn interval(&self, period: Duration) -> impl Stream<Item = ()> + Send + 'static
Stream that yields a () on the provided periodSource§fn spawn<Fut>(
&self,
fut: Fut,
) -> DroppableFuture<impl Future<Output = Option<Fut::Output>> + Send + 'static> ⓘ
fn spawn<Fut>( &self, fut: Fut, ) -> DroppableFuture<impl Future<Output = Option<Fut::Output>> + Send + 'static> ⓘ
Source§fn spawn_detached<Fut>(&self, fut: Fut)
fn spawn_detached<Fut>(&self, fut: Fut)
Source§fn block_on<Fut>(&self, fut: Fut) -> Fut::Outputwhere
Fut: Future,
fn block_on<Fut>(&self, fut: Fut) -> Fut::Outputwhere
Fut: Future,
Source§fn hook_signals(
&self,
signals: impl IntoIterator<Item = i32>,
) -> impl Stream<Item = i32> + Send + 'static
fn hook_signals( &self, signals: impl IntoIterator<Item = i32>, ) -> impl Stream<Item = i32> + Send + 'static
Stream of signals that match the provided signals