Skip to main content

TaskThread

Struct TaskThread 

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

线程所属域;不是执行器(executor),不包含任务(Task)选择或轮询循环。

只能在创建线程使用。活跃登记保住本地原值,不以外部Waker存在作为关停清理依据。 关闭先禁后续poll,再在合法线程清理;不能从正在进行的poll中间切断。

Implementations§

§

impl TaskThread

pub fn new() -> Self

建立当前线程的所属域;身份不复用,耗尽时中止。域本身不启动线程或轮询(poll)。

§

impl TaskThread

pub fn id(&self) -> TaskOwnerId

取得固定所属域身份;O(1),不改变登记或执行状态。

§

impl TaskThread

pub fn is_closed(&self) -> bool

在本线程查询是否停止接纳新任务(Task),O(1);不代表原值均已析构(drop)。

§

impl TaskThread

pub fn live_tasks(&self) -> usize

查询本域仍承担原值清理责任的任务数,不等于队列(queue)长度。

§

impl TaskThread

pub fn close(&self)

停止本域接纳并请求全部登记任务(Task)退出;幂等,不中断已开始轮询(poll)。 当前无访问时在本线程清理,存在访问则由退出交接继续负责;不承诺完成时限。 独立用户析构(drop)或通知恐慌(panic)立即向调用者传播,剩余登记仍由本域持有。 本方法不采用所属域析构(owner-domain drop)的暂存首错规则。

Trait Implementations§

§

impl Drop for TaskThread

§

fn drop(&mut self)

结束线程所属责任;不等待其它线程释放观察句柄。 进入前无异常展开(unwinding)时,首次可捕获的清理或通知恐慌(panic)暂存; 在原线程处理其它原值及本库等待责任后,继续传播原恐慌载荷(panic payload)。 失败原异步计算(Future)不重试(retry)、不报告成功清理;已确认事实不因通知(notification)失败回退。 已暂存首错后再次恐慌(panic),或进入前已展开而又发生新错误时,中止进程(abort)。 恐慌中止模式(panic=abort)及无法越过清理边界的再次恐慌(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, 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.