pub trait AsyncRuntimeExt<O: Default + 'static = ()> {
// Required methods
fn spawn_with_context<F, C>(
&self,
task_id: TaskId,
future: F,
context: C,
) -> Result<()>
where F: Future<Output = O> + Send + 'static,
C: 'static;
fn spawn_timing_with_context<F, C>(
&self,
task_id: TaskId,
future: F,
context: C,
time: usize,
) -> Result<()>
where F: Future<Output = O> + Send + 'static,
C: Send + 'static;
fn block_on<F>(&self, future: F) -> Result<F::Output>
where F: Future + Send + 'static,
<F as Future>::Output: Default + Send + 'static;
}
Expand description
异步运行时扩展
Required Methods§
Sourcefn spawn_with_context<F, C>(
&self,
task_id: TaskId,
future: F,
context: C,
) -> Result<()>
fn spawn_with_context<F, C>( &self, task_id: TaskId, future: F, context: C, ) -> Result<()>
派发一个指定的异步任务到异步运行时,并指定异步任务的初始化上下文
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.