Skip to main content

ControlHandle

Struct ControlHandle 

pub struct ControlHandle { /* private fields */ }
Expand description

共享且线程安全(thread-safe)的控制句柄;不授予轮询(poll)或结果领取权。

Implementations§

§

impl ControlHandle

pub fn id(&self) -> TaskId

取得原任务(Task)固定身份。

§

impl ControlHandle

pub fn snapshot(&self) -> TaskSnapshot

无阻塞(nonblocking)地查询基本状态快照(snapshot),不保证保存值自动更新。

§

impl ControlHandle

pub fn cancel(&self)

同步非阻塞(synchronous nonblocking)、线程安全(thread-safe)、幂等地提出取消请求(cancellation request),无返回值。 不承诺送达/受理或成功;已开始本次poll返回Ready仍保留正常结果。

§

impl ControlHandle

pub fn wake(&self)

提出原目标后续推进需求,重复任务唤醒(wake-up)可合并;不复活终结任务(Task)。

§

impl ControlHandle

pub fn waker(&self) -> Waker

取得原目标标准唤醒器(Waker),不授予元数据或输出访问。

§

impl ControlHandle

pub fn cancel_and_wait(&self) -> CancelWait ⓘ

创建惰性取消等待(cancellation wait);首次poll才检查并发送,结果仅为控制分类。 目标已有同步请求时允许首份合法等待接续;同目标仅一份持续等待。

§

impl ControlHandle

pub fn cancel_and_wait_from(&self, waiter: &ExternalWaiter) -> CancelWait ⓘ

使用可信外部等待者凭据创建同类等待;受管任务(Task)内仍以实际当前身份为准。

§

impl ControlHandle

pub fn is_waiting_for_wake(&self) -> bool

查询原任务(Task)是否仍在等待一次新的任务唤醒(wake-up)。

返回true表示原根异步计算(root Future)已经返回挂起(Pending)、完成交接, 且本次取样时没有执行访问、待处理唤醒(wake-up)、已发出的可执行持有、取消(cancellation)或退出。 正在轮询(poll)、正在交接、已唤醒但尚未入队(enqueue)及已经结束均返回false; false本身不能证明任务(Task)已结束或已经入队(enqueue)。

线程安全(thread-safe)、同步非阻塞(synchronous nonblocking)。只读取一次现有状态, 时间与额外空间均为O(1),不分配、不推进或唤醒(wake-up)任务(Task)。 返回的是取样结果,之后可能立即失效;与其它独立查询不构成同一时刻快照(snapshot)。 不判断目标属于哪个运行时(runtime)或是否已被接纳(admission),不据此授予执行权限。

§

impl ControlHandle

pub fn query_handle(&self) -> TaskQuery

取得同一原任务(Task)的只读查询句柄(query handle)。

Trait Implementations§

§

impl Clone for ControlHandle

§

fn clone(&self) -> Self

增加共享控制持有,不复制任务(Task)或取消等待权限。

1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more

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