Skip to main content

MpscEntryHandle

Struct MpscEntryHandle 

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

唯一持有一个MPSC节点(node)的透明句柄(transparent handle)。

可跨线程移动(Send),不支持Clone、Copy或Default,不承诺Sync。 它可以进入cordyceps原生队列(queue);安全取出后可恢复原Runnable或再次交接。 释放(drop)业务句柄(handle)等同放弃其中原Runnable的执行责任; 已绑定任务(Task)的原异步计算(Future)仍交原线程合法清理,不保证本次返回就已清理。 释放(drop)独立空节点(node)只结束其存储(storage),不会取消任何业务任务(Task)。 释放(drop)可能沿原任务(Task)路径执行用户清理或调度(Schedule),其成本和 恐慌(panic)继续由原规则决定;不能把整个释放(drop)承诺为同步非阻塞(nonblocking)。

Implementations§

§

impl MpscEntryHandle

pub fn try_from_runnable(task: Runnable) -> Result<Self, Runnable>

将原Runnable的唯一执行持有移入其MPSC节点(node),不提交(submission)或接纳(admission)。

task可来自跨线程或本地创建入口;节点(node)能力由创建选项固定。 成功返回同一任务(Task)的唯一句柄(handle);没有MPSC链接(link)时 返回Err(task),保留原身份及执行责任,不取消(cancel)或隐式释放(drop)原值。 O(1)时间及额外空间,不分配、不等待、不轮询(poll)、不增加强引用(strong reference)。

§

impl MpscEntryHandle

pub fn try_into_runnable(self) -> Result<Runnable, Self>

消费当前句柄(handle),尝试取回原Runnable。

业务节点(node)返回Ok(原Runnable),不会创建新任务(Task)或改变原归属; 独立空节点(node)返回Err(原self),保持原独立存储(storage)及唯一持有。 原生容器(container)尚未安全归还时不能另造句柄(handle)调用本方法。 O(1)时间及额外空间,不分配、不等待、不执行用户代码,不释放(drop)取回的Runnable。

§

impl MpscEntryHandle

pub fn try_new_empty() -> Result<Self>

显式分配并持有一个不关联业务任务(Task)的独立空节点(node)。

可供cordyceps的new_with_stub或其它合法空节点(node)用途使用;各用途须各建实例(instance)。 成功只交出一份唯一持有;检测到分配失败时返回pi_result错误报告(error report), 不发布半初始化值,也不创建、轮询(poll)或取消(cancel)业务任务(Task)。 O(1)额外存储(storage),实际分配器(allocator)及错误报告(error report)的 分配成本和失败策略不保证非阻塞(nonblocking)或总能恢复。

Trait Implementations§

§

impl Drop for MpscEntryHandle

§

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 Send for MpscEntryHandle

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.