pub struct SingleTaskRuntime<O: Default + 'static = (), P: AsyncTaskPoolExt<O> + AsyncTaskPool<O> = SingleTaskPool<O>>(/* private fields */);
Expand description
异步单线程任务运行时
Implementations§
Source§impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> SingleTaskRuntime<O, P>
impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> SingleTaskRuntime<O, P>
Sourcepub fn to_local_runtime(&self) -> LocalAsyncRuntime<O>
pub fn to_local_runtime(&self) -> LocalAsyncRuntime<O>
获取当前单线程异步运行时的本地异步运行时
Trait Implementations§
Source§impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> AsyncRuntime<O> for SingleTaskRuntime<O, P>
impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> AsyncRuntime<O> for SingleTaskRuntime<O, P>
共享运行时内部任务池
Source§fn spawn_local<F>(&self, future: F) -> Result<TaskId>
fn spawn_local<F>(&self, future: F) -> Result<TaskId>
派发一个异步任务到本地异步运行时,如果本地没有本异步运行时,则会派发到当前运行时中
Source§fn spawn_priority<F>(&self, priority: usize, future: F) -> Result<TaskId>
fn spawn_priority<F>(&self, priority: usize, future: F) -> Result<TaskId>
派发一个指定优先级的异步任务到异步运行时
Source§fn spawn_yield<F>(&self, future: F) -> Result<TaskId>
fn spawn_yield<F>(&self, future: F) -> Result<TaskId>
派发一个异步任务到异步运行时,并立即让出任务的当前运行
Source§fn spawn_timing<F>(&self, future: F, time: usize) -> Result<TaskId>
fn spawn_timing<F>(&self, future: F, time: usize) -> Result<TaskId>
派发一个在指定时间后执行的异步任务到异步运行时,时间单位ms
Source§fn spawn_local_by_id<F>(&self, task_id: TaskId, future: F) -> Result<()>
fn spawn_local_by_id<F>(&self, task_id: TaskId, future: F) -> Result<()>
派发一个指定任务唯一id的异步任务到本地异步运行时,如果本地没有本异步运行时,则会派发到当前运行时中
Source§fn spawn_priority_by_id<F>(
&self,
task_id: TaskId,
priority: usize,
future: F,
) -> Result<()>
fn spawn_priority_by_id<F>( &self, task_id: TaskId, priority: usize, future: F, ) -> Result<()>
派发一个指定任务唯一id和任务优先级的异步任务到异步运行时
Source§fn spawn_yield_by_id<F>(&self, task_id: TaskId, future: F) -> Result<()>
fn spawn_yield_by_id<F>(&self, task_id: TaskId, future: F) -> Result<()>
派发一个指定任务唯一id的异步任务到异步运行时,并立即让出任务的当前运行
Source§fn spawn_timing_by_id<F>(
&self,
task_id: TaskId,
future: F,
time: usize,
) -> Result<()>
fn spawn_timing_by_id<F>( &self, task_id: TaskId, future: F, time: usize, ) -> Result<()>
派发一个指定任务唯一id和在指定时间后执行的异步任务到异步运行时,时间单位ms
Source§fn pending<Output: 'static>(
&self,
task_id: &TaskId,
waker: Waker,
) -> Poll<Output>
fn pending<Output: 'static>( &self, task_id: &TaskId, waker: Waker, ) -> Poll<Output>
挂起指定唯一id的异步任务
Source§fn wait<V: Send + 'static>(&self) -> AsyncWait<V>
fn wait<V: Send + 'static>(&self) -> AsyncWait<V>
挂起当前异步运行时的当前任务,并在指定的其它运行时上派发一个指定的异步任务,等待其它运行时上的异步任务完成后,唤醒当前运行时的当前任务,并返回其它运行时上的异步任务的值
Source§fn wait_any<V: Send + 'static>(&self, capacity: usize) -> AsyncWaitAny<V>
fn wait_any<V: Send + 'static>(&self, capacity: usize) -> AsyncWaitAny<V>
挂起当前异步运行时的当前任务,并在多个其它运行时上执行多个其它任务,其中任意一个任务完成,则唤醒当前运行时的当前任务,并返回这个已完成任务的值,而其它未完成的任务的值将被忽略
Source§fn wait_any_callback<V: Send + 'static>(
&self,
capacity: usize,
) -> AsyncWaitAnyCallback<V>
fn wait_any_callback<V: Send + 'static>( &self, capacity: usize, ) -> AsyncWaitAnyCallback<V>
挂起当前异步运行时的当前任务,并在多个其它运行时上执行多个其它任务,任务返回后需要通过用户指定的检查回调进行检查,其中任意一个任务检查通过,则唤醒当前运行时的当前任务,并返回这个已完成任务的值,而其它未完成或未检查通过的任务的值将被忽略,如果所有任务都未检查通过,则强制唤醒当前运行时的当前任务
Source§fn map_reduce<V: Send + 'static>(&self, capacity: usize) -> AsyncMapReduce<V>
fn map_reduce<V: Send + 'static>(&self, capacity: usize) -> AsyncMapReduce<V>
构建用于派发多个异步任务到指定运行时的映射归并,需要指定映射归并的容量
Source§fn pipeline<S, SO, F, FO>(&self, input: S, filter: F) -> BoxStream<'static, FO>
fn pipeline<S, SO, F, FO>(&self, input: S, filter: F) -> BoxStream<'static, FO>
生成一个异步管道,输入指定流,输入流的每个值通过过滤器生成输出流的值
type Pool = P
Source§impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> AsyncRuntimeExt<O> for SingleTaskRuntime<O, P>
impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> AsyncRuntimeExt<O> for SingleTaskRuntime<O, P>
Source§impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O>> Clone for SingleTaskRuntime<O, P>
impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O>> Clone for SingleTaskRuntime<O, P>
impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O>> Send for SingleTaskRuntime<O, P>
impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O>> Sync for SingleTaskRuntime<O, P>
Auto Trait Implementations§
impl<O, P> Freeze for SingleTaskRuntime<O, P>
impl<O = (), P = SingleTaskPool<O>> !RefUnwindSafe for SingleTaskRuntime<O, P>
impl<O, P> Unpin for SingleTaskRuntime<O, P>
impl<O = (), P = SingleTaskPool<O>> !UnwindSafe for SingleTaskRuntime<O, P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more