Skip to main content

TaskQueue

Struct TaskQueue 

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

与所属域绑定的本地任务队列(task queue);不可跨线程转移或共享。

Implementations§

§

impl TaskQueue

pub fn new(owner: &TaskThread) -> Self

建立与当前所属域绑定的空队列(queue);不接纳或执行任务(Task)。

§

impl TaskQueue

pub fn owner_id(&self) -> TaskOwnerId

取得不可更换的所属域身份,O(1)。

§

impl TaskQueue

pub fn len(&self) -> usize

查询本队列当前精确数量,O(1),不含外部队列及执行中任务。

§

impl TaskQueue

pub fn is_empty(&self) -> bool

只判断本地是否无节点,不证明运行时(runtime)可以结束。

§

impl TaskQueue

pub fn push_front(&mut self, task: Runnable) -> Result<(), QueuePushError>

将本地任务放到队首,影响下一次选择,不打断当前轮询(poll)。 失败返还原值;不隐式接纳到执行器(executor)。 关闭后优先返回Closed,O(1)且不访问节点(node)或执行原值。

§

impl TaskQueue

pub fn pop_front(&mut self) -> Option<Runnable>

从队首取出唯一可执行持有;空时None,不轮询(poll)。

§

impl TaskQueue

pub fn push_back(&mut self, task: Runnable) -> Result<(), QueuePushError>

将任务(Task)放到队尾;挂起(Pending)后重新唤醒默认走此入口。 失败返还原值;不隐式接纳到执行器(executor)。 关闭后优先返回Closed,O(1)且不访问节点(node)或执行原值。

§

impl TaskQueue

pub fn pop_back(&mut self) -> Option<Runnable>

从队尾取出唯一可执行持有;空时None,不轮询(poll)。

§

impl TaskQueue

pub fn append_batch( &mut self, batch: TaskBatch, ) -> Result<usize, BatchPushError>

把外部单次获取的有序批次完整追加到队尾,返回追加数量。 先完整预检查;失败返回原批次,不留下部分成功前缀。O(n),不等待新增任务。 关闭后优先返回Closed,保留完整原批次(TaskBatch)及顺序;此路径O(1)。

§

impl TaskQueue

pub fn drain(&mut self) -> TaskBatch

按队首顺序取回全部当前持有,返回批次;不执行或自动取消它们。

§

impl TaskQueue

pub fn clear(&mut self) -> Result<QueueCleanupProgress>

在队列(queue)内部清理当前全部持有,保持接收的开放/关闭标记,不轮询(poll)。

在所属线程(owner thread)通过排他借用同步完成;无并发提交扩展本次范围。 不返回待清理批次(TaskBatch),按原Runnable的合法释放(drop)路径处理; Complete不保证原异步计算(Future)已确认析构(drop)。 无新增内容时重复调用不重复释放;O(n)处理当前数量,不等待其它线程(thread)。 本地实现当前无可恢复错误;分配或原有操作的恐慌(panic)不转换为伪成功。

§

impl TaskQueue

pub fn close(&mut self) -> Result<QueueCleanupProgress>

永久停止压入,再按clear内部处理全部当前持有;幂等(idempotent),不重新开放。

push_front、push_back、append_batch从停收后返还原值和Closed分类。 已有弹出、drain及析构(Drop)仍处理余项,不因停收跳过清理。 返回语义、所属线程(owner thread)及成本同clear;若清理异常,停收标记仍保持。 完成只确认本队列(queue)的责任结束/合法移交,不确认任务(Task)取消成功或全部退出。

Trait Implementations§

§

impl Drop for TaskQueue

§

fn drop(&mut self)

归还所有队列持有并正常释放;不遗留节点内自持有环,不直接推进业务原值。

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.