Skip to main content

TaskHandle

Struct TaskHandle 

pub struct TaskHandle<N: TaskNotifier, T, M: Send + Sync + 'static = (), K: OutputMode = SendOutput> { /* private fields */ }
Expand description

唯一可等待结果与共享控制组合;本地输出模式保持原线程限制。 作为异步计算(Future)等待时,只领取原输出或原TaskError;不会隐式提交尚未提交的任务。 输出值自身的错误与任务(Task)级失败分别保留;领取后再次轮询(poll)返回TaskError::AlreadyTaken。 释放(drop)只放弃结果兴趣,不自动取消后台任务;本地输出仍限原所属线程(owner thread)。

Implementations§

§

impl<N: TaskNotifier, T, M: Send + Sync + 'static, K: OutputMode> TaskHandle<N, T, M, K>

pub fn id(&self) -> TaskId

读取原服务或任务(Task)的固定身份;不创建新身份或权限。

pub fn snapshot(&self) -> TaskSnapshot

读取原任务(Task)的基本事实,多个原子量不保证全局同一瞬间;不代表物理队列位置。

pub fn metadata(&self) -> &M

同步借用创建时同类型附加数据;引用不得超过原持有借用期,写入需使用数据自身的安全接口。

pub fn control_handle(&self) -> TaskControl<N>

按需克隆同一原目标的控制权限,不复制执行权限或改变取消事实。

pub fn query_handle(&self) -> TaskQuery

取得相同任务(Task)的只读查询,不取得另一份结果或控制权限。

Trait Implementations§

§

impl<N: TaskNotifier, T, M: Send + Sync + 'static, K: OutputMode> Future for TaskHandle<N, T, M, K>

§

type Output = Result<T, TaskError>

The type of value produced on completion.
§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
§

impl<N: TaskNotifier, T, M: Send + Sync + 'static, K: OutputMode> Unpin for TaskHandle<N, T, M, K>

Auto Trait Implementations§

§

impl<N, T, M = (), K = SendOutput> !RefUnwindSafe for TaskHandle<N, T, M, K>

§

impl<N, T, M = (), K = SendOutput> !UnwindSafe for TaskHandle<N, T, M, K>

§

impl<N, T, M, K> Forget for TaskHandle<N, T, M, K>

§

impl<N, T, M, K> Freeze for TaskHandle<N, T, M, K>
where JoinHandle<T, M, K>: Freeze, TaskControl<N>: Freeze,

§

impl<N, T, M, K> Move for TaskHandle<N, T, M, K>

§

impl<N, T, M, K> Send for TaskHandle<N, T, M, K>
where JoinHandle<T, M, K>: Send, TaskControl<N>: Send,

§

impl<N, T, M, K> Sync for TaskHandle<N, T, M, K>
where JoinHandle<T, M, K>: Sync, TaskControl<N>: Sync,

§

impl<N, T, M, K> UnsafeUnpin for TaskHandle<N, T, M, K>

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<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
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.