Skip to main content

JoinHandle

Struct JoinHandle 

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

唯一结果句柄(result handle),不支持Clone或复制(Copy)。

单次领取Result<T,TaskError>;业务T可以自身是Result,不据此决定控制完成分类。 本地模式不能跨线程;共享ControlHandle不获得本句柄的权限。

Implementations§

§

impl<T, M: Send + Sync + 'static, K: OutputMode> JoinHandle<T, M, K>

pub fn id(&self) -> TaskId

取得原任务(Task)固定身份,不消耗领取权。

§

impl<T, M: Send + Sync + 'static, K: OutputMode> JoinHandle<T, M, K>

pub fn snapshot(&self) -> TaskSnapshot

线程安全(thread-safe)地观察当前任务(Task)基本事实,不等同结果已领取。

§

impl<T, M: Send + Sync + 'static, K: OutputMode> JoinHandle<T, M, K>

pub fn metadata(&self) -> &M

借用创建时同类型附加数据;引用不超过本句柄借用期。

Trait Implementations§

§

impl<T, M: Send + Sync + 'static, K: OutputMode> Drop for JoinHandle<T, M, K>

§

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<T, M: Send + Sync + 'static, K: OutputMode> Future for JoinHandle<T, M, K>

§

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

等待并唯一领取输出(output);未就绪登记当前唤醒器(Waker)。 领取后再次poll返回AlreadyTaken,不重复领取或制造默认T。

§

type Output = Result<T, TaskError>

The type of value produced on completion.
§

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

Auto Trait Implementations§

§

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

§

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

§

impl<T, M, K> Forget for JoinHandle<T, M, K>

§

impl<T, M, K> Freeze for JoinHandle<T, M, K>

§

impl<T, M, K> Move for JoinHandle<T, M, K>

§

impl<T, M, K> Send for JoinHandle<T, M, K>

§

impl<T, M, K> Sync for JoinHandle<T, M, K>

§

impl<T, M, K> UnsafeUnpin for JoinHandle<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.