Skip to main content

QueueEntry

Struct QueueEntry 

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

嵌入任务存储(task allocation)的本地链节点;不单独堆分配。

队列持有的Runnable暂存于ticket;这是一份有明确进出责任的自引用持有, 出队或队列析构(drop)必须取回它。普通控制句柄不能访问此槽或链接。

Implementations§

§

impl QueueEntry

取得内嵌链接地址;不导出任务(Task)状态。

§Safety

node须来自仍存活且未移动的QueueEntry,并持有对应队列访问权及保活责任。

§

impl QueueEntry

仅用于对应适配器(adapter)的逆向地址换算。

§Safety

link必须确由link_from_node取得,节点仍保活且属于当前队列;不能传任意指针。

§

impl QueueEntry

pub unsafe fn store( task: Runnable, owner: TaskOwnerId, ) -> Result<NonNull<Self>, Runnable>

把唯一可执行持有移入自身节点;失败原样返回。

§Safety

调用者须在owner线程,独占准备插入的节点,随后承担入链成功或回退取回责任。

§

impl QueueEntry

pub unsafe fn take(node: NonNull<Self>, owner: TaskOwnerId) -> Runnable

已安全摘链后取回唯一可执行持有,使链接可复用。

§Safety

须为本队列已完全摘除的保活节点,当前owner线程且只取一次。

§

impl QueueEntry

pub unsafe fn store_with_unbound( task: Runnable, owner: TaskOwnerId, ) -> Result<NonNull<QueueEntry>, Runnable>

将未绑定或属于 owner 的唯一可执行句柄(Runnable)存入原本地链节点。 按接口约定,成功时返回原节点地址,由存入的原值保持有效。 其它所属域(owner)、缺少本地链接(link)、链接或保管槽已占用时,返还同一个 Runnable。 存入保留原所属域和接纳(admission)事实。正常操作同步完成,时间及额外空间均为 O(1), 无需分配(allocation)、等待或调用用户代码。

§Safety

task 是本次交接的唯一可执行句柄(Runnable)。owner 是当前队列的实际所属域。 调用者须在队列的所属线程(owner thread),对实际访问的节点链接和保管槽拥有排他访问权。 成功后,调用者负责完成入链或撤销。原节点从未入链或已完整摘链(unlink)时, 必须由同一队列用 Self::take_with_unbound 取回一次,包括关闭(close)时。

pub unsafe fn take_with_unbound( node: NonNull<QueueEntry>, owner: TaskOwnerId, ) -> Runnable

从原节点取回由 Self::store_with_unbound 存入的同一个可执行句柄(Runnable)。 按接口约定,取回后由调用者拥有原值并承担后续处理责任。原所属域(owner)和接纳(admission)事实保持。 正常操作同步完成,时间及额外空间均为 O(1),无需分配(allocation)、等待或调用用户代码。

§Safety

node 必须来自同一队列本次成功的存入,且仍由原可执行句柄(Runnable)保活。 调用者须在该队列的所属线程(owner thread),持有节点排他访问权及本次唯一取回权。 owner 必须与存入时一致。该节点须从未入链或已完整摘链(unlink)。 取回后,本次存入提供的指针访问权限结束。随后处理原任务(Task)前须结束队列借用。

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.