Skip to main content

TaskPoolQueue

Struct TaskPoolQueue 

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

默认外部共享任务池适配;只通过本对象提交和获取才能保持计数契约。

若队列中任务(Task)的交付实现也持有本队列,会形成强持有环;宿主必须显式关闭并 取回/移交全部队列持有,单纯释放外部句柄不保证触发Drop。原生池本体仍保留静态分配。

Implementations§

§

impl TaskPoolQueue

pub fn new(random: fn() -> u64) -> Self

创建私有适配池;random须快速、线程安全(thread-safe)、不阻塞,返回任意u64。 原生池构造保留静态分配,不承诺Drop回收池本体;应复用实例。

§

impl TaskPoolQueue

pub fn close(&self) -> BatchAttempt

停止新接纳并尝试取回当前任务(Task);Busy/WouldBlock可继续调用,不等待消费者。 关闭后的剩余任务仍须由合法所属域清理,不因此消失。

Trait Implementations§

§

impl Drop for TaskPoolQueue

§

fn drop(&mut self)

关闭并归还队列仍持有的任务(Task);不宣称回收原生静态池本体。

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 ExternalTaskQueue for TaskPoolQueue

§

fn try_push(&self, task: Runnable) -> Result<(), ExternalPushError>

单次尝试外部提交(submission),拒绝包含原Runnable;不执行原异步计算(Future)。

§

fn try_take_batch(&self) -> BatchAttempt

单次同步获取当前可取批次;保持原生pop选出顺序,不保证全局FIFO。

§

fn len(&self) -> usize

单次原子读取适配队列精确逻辑数量;不把粗略权重提示相加。

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.