Skip to main content

Runnable

Struct Runnable 

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

唯一待执行持有;移动(move)不复制任务(Task),不支持Clone。 调用run前后均不能另借出F;进入队列(queue)后由队列保有本份值。

Implementations§

§

impl Runnable

pub fn id(&self) -> TaskId

取得原任务(Task)固定身份,O(1),不增加持有。

§

impl Runnable

pub fn admit( &self, owner: &TaskThread, ) -> Result<TaskRegistration, AdmissionError>

将任务(Task)交给指定所属域管理;接纳(admission)与实际入队(enqueue)分离。 明确拒绝不消费本句柄、不自动取消,调用方可重试或另作合法安排。

§

impl Runnable

pub fn run(self, owner: &TaskThread) -> Result<RunOutcome, RunError>

消费本份执行持有,至多直接轮询(poll)一次,或只做合法退出清理。 返回Pending前完成必要交接;外部Schedule负责真正排队。拒绝须返还原持有。

§

impl Runnable

pub fn snapshot(&self) -> TaskSnapshot

取得基本状态快照(snapshot),不报告物理队列位置。

§

impl Runnable

pub fn metadata<M: Send + Sync + 'static>(&self) -> Option<&M>

按创建时类型(type)借用附加数据,类型不匹配返回None;不转移所有权。

§

impl Runnable

pub fn query_handle(&self) -> TaskQuery

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

Trait Implementations§

§

impl Drop for Runnable

§

fn drop(&mut self)

放弃本份唯一执行持有;按任务(Task)当前归属合法退出,不直接轮询(poll)。 未接纳(admission)且从未轮询(poll)的初始放弃保留Abandoned分类。 已绑定者交回原线程清理,不等待其它控制句柄释放;本次返回不代表清理已经完成。 未绑定且满足Send的原异步计算(Future)可在本次调用析构(drop)。 用户析构(drop)或调度接口(Schedule)的恐慌(panic)继续向外传播。

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> 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, 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.