Trait mz_ore::future::OreFutureExt
source · pub trait OreFutureExt {
// Required methods
fn spawn_if_canceled<Name, NameClosure>(
self,
nc: NameClosure,
) -> SpawnIfCanceled<Self::Output, Name, NameClosure> ⓘ
where Name: AsRef<str>,
NameClosure: FnOnce() -> Name + Unpin,
Self: Future + Send + 'static,
Self::Output: Send + 'static;
fn run_in_task<'async_trait, Name, NameClosure>(
self,
nc: NameClosure,
) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
where Name: AsRef<str> + 'async_trait,
NameClosure: FnOnce() -> Name + Unpin + Send + 'async_trait,
Self: Future + Send + 'static + 'async_trait,
Self::Output: Send + 'static;
fn run_in_task_if<'async_trait, Name, NameClosure>(
self,
in_task: InTask,
nc: NameClosure,
) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
where Name: AsRef<str> + 'async_trait,
NameClosure: FnOnce() -> Name + Unpin + Send + 'async_trait,
Self: Future + Send + 'static + 'async_trait,
Self::Output: Send + 'static;
fn ore_catch_unwind(self) -> OreCatchUnwind<Self> ⓘ
where Self: Sized + UnwindSafe;
}
Available on crate feature
async
only.Expand description
Extension methods for futures.
Required Methods§
sourcefn spawn_if_canceled<Name, NameClosure>(
self,
nc: NameClosure,
) -> SpawnIfCanceled<Self::Output, Name, NameClosure> ⓘ
fn spawn_if_canceled<Name, NameClosure>( self, nc: NameClosure, ) -> SpawnIfCanceled<Self::Output, Name, NameClosure> ⓘ
Wraps a future in a SpawnIfCanceled
future, which will spawn a
task to poll the inner future to completion if it is dropped.
sourcefn run_in_task<'async_trait, Name, NameClosure>(
self,
nc: NameClosure,
) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
fn run_in_task<'async_trait, Name, NameClosure>( self, nc: NameClosure, ) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
Run a 'static
future in a Tokio task, naming that task, using a convenient
postfix call notation.
Useful in contexts where futures may be starved and cause inadvertent failures in I/O-sensitive operations, such as when called within timely operators.
sourcefn run_in_task_if<'async_trait, Name, NameClosure>(
self,
in_task: InTask,
nc: NameClosure,
) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
fn run_in_task_if<'async_trait, Name, NameClosure>( self, in_task: InTask, nc: NameClosure, ) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
The same as run_in_task
, but allows the callee to dynamically choose whether or
not the future is polled into a Tokio task.
sourcefn ore_catch_unwind(self) -> OreCatchUnwind<Self> ⓘwhere
Self: Sized + UnwindSafe,
fn ore_catch_unwind(self) -> OreCatchUnwind<Self> ⓘwhere
Self: Sized + UnwindSafe,
Like FutureExt::catch_unwind
, but can unwind panics even if
panic::install_enhanced_handler
has been called.
Object Safety§
This trait is not object safe.