Skip to main content

TaskPhase

Enum TaskPhase 

pub enum TaskPhase {
    Preparing,
    Advancing,
    Exiting,
    Ended,
}
Expand description

描述单个任务(Task)的生命周期(lifecycle)所处的最高层阶段。

阶段值不持有任务(Task)或异步计算(Future),不授予执行或控制权限。 复制(copy)本值只产生另一份相同的描述值,不创建、提交或推进任务(Task)。 本类型(type)本身不提供实时查询,也不保证某个外部观察入口能够取得全部阶段。

§使用示例(Usage)

use pi_async_task::definitions::TaskPhase;

let phase = TaskPhase::Preparing;
let another_copy = phase;

§成本与安全(Cost and safety)

普通构造、复制(copy)及相等比较均为 O(1),无需堆分配、锁(lock)、 异步等待(await)或用户回调(callback),不修改任何实际任务(Task)。 本值可在线程(thread)之间转移或通过共享引用(shared reference)读取。 调试(debug)输出的成本和行为取决于调用方提供的格式化(formatting)目标。

不保证内存布局(memory layout)或判别值(discriminant)的具体数值; 不应将它们用作实际任务(Task)的内部编码或外部稳定数据格式。

Variants§

§

Preparing

准备阶段(Preparation phase):已成功建立,尚未开始首次合法轮询(poll)。

尚未提交(submission)和已接纳(admission)但尚未首次轮询(poll)的任务(Task), 都属于此阶段。取消(cancellation)落实可使其直接进入退出处理。

§

Advancing

计算推进阶段(Computation advancement phase):首次合法轮询(poll)已经开始, 但尚未满足退出处理的条件。

该阶段涵盖正在轮询(poll)、挂起(Pending)及必要交接, 不表示此刻一定有执行者正在调用轮询(poll)。

§

Exiting

退出处理阶段(Exit-handling phase):当前没有轮询(poll), 并且已经永久停止后续轮询(poll),仍在处理自身退出责任。

原异步计算(Future)的合法析构(drop)可能尚未完成; 单纯记录取消请求(cancellation request)不等于已经进入此阶段。

§

Ended

本任务全部自身责任已结束(Task responsibilities ended): 原异步计算(Future)已合法析构(drop),自身责任全部完成或合法移交。

不表示分配器(allocator)已经归还存储,也不要求已经合法交给外部的值全部销毁。

Trait Implementations§

Source§

impl Clone for TaskPhase

Source§

fn clone(&self) -> TaskPhase

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for TaskPhase

Source§

impl Debug for TaskPhase

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for TaskPhase

Source§

impl PartialEq for TaskPhase

Source§

fn eq(&self, other: &TaskPhase) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TaskPhase

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> OpaqueAttachment for T
where T: Send + Sync + 'static,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.