Skip to main content

MpscTaskQueue

Struct MpscTaskQueue 

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

默认MPSC来源的唯一管理对象,不支持Clone或Default。

通过ExternalQueueManager取得普通句柄(handle)、清理固定范围或永久关闭接收。 对象可跨线程转移和共享(Send + Sync),管理方法仍要求独占可变借用(&mut self)。 释放(drop)先停收并安排剩余来源责任,不以所有共享句柄(shared handle)消失为前提。 原任务(Task)的清理可能执行用户代码;整个关闭/析构(drop)不保证固定耗时。

Implementations§

§

impl MpscTaskQueue

pub fn new(options: MpscQueueOptions) -> Result<Self>

创建独立空来源,保管两份不同用途的空节点(node),不创建业务任务(Task)。

显式节点(node)分配失败返回pi_result错误报告(error report);已建资源正常归还。 标准共享分配的失败策略仍由分配器(allocator)决定,不承诺所有分配失败均可恢复。 数量上限为usize::MAX >> 3。构造成本含常数份分配;普通提交不新增每任务分配。

Trait Implementations§

§

impl Drop for MpscTaskQueue

§

fn drop(&mut self)

Executes the destructor for this type. Read more
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
§

impl ExternalQueueManager for MpscTaskQueue

§

fn handle(&self) -> Self::Handle

取得同一来源的共享访问;仅增加同一Arc持有,O(1)。

§

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

内部处理首次调用固定的范围;后来的提交留待下一范围,保持当前接收状态。

每次至多检查cleanup_batch_size个节点(node),可能返回MoreWork并由随后调用继续。 本轮刚清理完终点前原值后,允许下一次调用作完成确认;不返回待清理批次。 未取得Consumer按pi_result报告Busy;错误不撤销已发生变化,余项仍由来源保管。 若接收已停止,按关闭责任接续,不重新开放。实际原值清理成本不保证固定上界。

§

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

永久停收并内部接续所有已接收责任;重复调用幂等(idempotent)。

包含先前清理及尚未完成发布的内容;MoreWork不是丢弃余项或等待发布的许可。 Complete要求来源的数量、终点及剩余责任满足结束条件,不等待所有句柄(handle)释放。 Busy按pi_result报告,首次清理恐慌(panic)继续传播,不重新开放、不重试失败原值。

§

type Handle = MpscTaskQueueHandle

同一原来源的普通共享访问;不是另一队列(queue)或另一份计数。

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.