Struct SingleTaskRuntime

Source
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>

Source

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>

Source§

fn shared_pool(&self) -> Arc<Self::Pool>

共享运行时内部任务池

Source§

fn get_id(&self) -> usize

获取当前异步运行时的唯一id

Source§

fn wait_len(&self) -> usize

获取当前异步运行时待处理任务数量

Source§

fn len(&self) -> usize

获取当前异步运行时任务数量

Source§

fn alloc<R: 'static>(&self) -> TaskId

分配异步任务的唯一id

Source§

fn spawn<F>(&self, future: F) -> Result<TaskId>
where F: Future<Output = O> + Send + 'static,

派发一个指定的异步任务到异步运行时

Source§

fn spawn_local<F>(&self, future: F) -> Result<TaskId>
where F: Future<Output = O> + Send + 'static,

派发一个异步任务到本地异步运行时,如果本地没有本异步运行时,则会派发到当前运行时中

Source§

fn spawn_priority<F>(&self, priority: usize, future: F) -> Result<TaskId>
where F: Future<Output = O> + Send + 'static,

派发一个指定优先级的异步任务到异步运行时

Source§

fn spawn_yield<F>(&self, future: F) -> Result<TaskId>
where F: Future<Output = O> + Send + 'static,

派发一个异步任务到异步运行时,并立即让出任务的当前运行

Source§

fn spawn_timing<F>(&self, future: F, time: usize) -> Result<TaskId>
where F: Future<Output = O> + Send + 'static,

派发一个在指定时间后执行的异步任务到异步运行时,时间单位ms

Source§

fn spawn_by_id<F>(&self, task_id: TaskId, future: F) -> Result<()>
where F: Future<Output = O> + Send + 'static,

派发一个指定任务唯一id的异步任务到异步运行时

Source§

fn spawn_local_by_id<F>(&self, task_id: TaskId, future: F) -> Result<()>
where F: Future<Output = O> + Send + 'static,

派发一个指定任务唯一id的异步任务到本地异步运行时,如果本地没有本异步运行时,则会派发到当前运行时中

Source§

fn spawn_priority_by_id<F>( &self, task_id: TaskId, priority: usize, future: F, ) -> Result<()>
where F: Future<Output = O> + Send + 'static,

派发一个指定任务唯一id和任务优先级的异步任务到异步运行时

Source§

fn spawn_yield_by_id<F>(&self, task_id: TaskId, future: F) -> Result<()>
where F: Future<Output = O> + Send + 'static,

派发一个指定任务唯一id的异步任务到异步运行时,并立即让出任务的当前运行

Source§

fn spawn_timing_by_id<F>( &self, task_id: TaskId, future: F, time: usize, ) -> Result<()>
where F: Future<Output = O> + Send + 'static,

派发一个指定任务唯一id和在指定时间后执行的异步任务到异步运行时,时间单位ms

Source§

fn pending<Output: 'static>( &self, task_id: &TaskId, waker: Waker, ) -> Poll<Output>

挂起指定唯一id的异步任务

Source§

fn wakeup<Output: 'static>(&self, task_id: &TaskId)

唤醒指定唯一id的异步任务

Source§

fn wait<V: Send + 'static>(&self) -> AsyncWait<V>

挂起当前异步运行时的当前任务,并在指定的其它运行时上派发一个指定的异步任务,等待其它运行时上的异步任务完成后,唤醒当前运行时的当前任务,并返回其它运行时上的异步任务的值

Source§

fn wait_any<V: Send + 'static>(&self, capacity: usize) -> AsyncWaitAny<V>

挂起当前异步运行时的当前任务,并在多个其它运行时上执行多个其它任务,其中任意一个任务完成,则唤醒当前运行时的当前任务,并返回这个已完成任务的值,而其它未完成的任务的值将被忽略

Source§

fn wait_any_callback<V: Send + 'static>( &self, capacity: usize, ) -> AsyncWaitAnyCallback<V>

挂起当前异步运行时的当前任务,并在多个其它运行时上执行多个其它任务,任务返回后需要通过用户指定的检查回调进行检查,其中任意一个任务检查通过,则唤醒当前运行时的当前任务,并返回这个已完成任务的值,而其它未完成或未检查通过的任务的值将被忽略,如果所有任务都未检查通过,则强制唤醒当前运行时的当前任务

Source§

fn map_reduce<V: Send + 'static>(&self, capacity: usize) -> AsyncMapReduce<V>

构建用于派发多个异步任务到指定运行时的映射归并,需要指定映射归并的容量

Source§

fn timeout(&self, timeout: usize) -> BoxFuture<'static, ()>

挂起当前异步运行时的当前任务,等待指定的时间后唤醒当前任务

Source§

fn yield_now(&self) -> BoxFuture<'static, ()>

立即让出当前任务的执行

Source§

fn pipeline<S, SO, F, FO>(&self, input: S, filter: F) -> BoxStream<'static, FO>
where S: Stream<Item = SO> + Send + 'static, SO: Send + 'static, F: FnMut(SO) -> AsyncPipelineResult<FO> + Send + 'static, FO: Send + 'static,

生成一个异步管道,输入指定流,输入流的每个值通过过滤器生成输出流的值

Source§

fn close(&self) -> bool

关闭异步运行时,返回请求关闭是否成功

Source§

type Pool = P

Source§

impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O, Pool = P>> AsyncRuntimeExt<O> for SingleTaskRuntime<O, P>

Source§

fn spawn_with_context<F, C>( &self, task_id: TaskId, future: F, context: C, ) -> Result<()>
where F: Future<Output = O> + Send + 'static, C: 'static,

派发一个指定的异步任务到异步运行时,并指定异步任务的初始化上下文
Source§

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,

派发一个在指定时间后执行的异步任务到异步运行时,并指定异步任务的初始化上下文,时间单位ms
Source§

fn block_on<F>(&self, future: F) -> Result<F::Output>
where F: Future + Send + 'static, <F as Future>::Output: Default + Send + 'static,

立即创建一个指定任务池的异步运行时,并执行指定的异步任务,阻塞当前线程,等待异步任务完成后返回
Source§

impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O>> Clone for SingleTaskRuntime<O, P>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<O: Default + 'static, P: AsyncTaskPoolExt<O> + AsyncTaskPool<O>> Send for SingleTaskRuntime<O, P>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ThreadSend for T
where T: Send,

Source§

impl<T> ThreadSync for T
where T: Sync + Send,