Skip to main content

Handle

Struct Handle 

Source
pub struct Handle<T>(/* private fields */);
Available on crate feature coroutine only.
Expand description

Join handle for async task

This is a wrapper around tokio’s JoinHandle type.

Implementations§

Source§

impl<T> Handle<T>

Source

pub fn into_robust(self) -> RobustHandle<T>

Convert this handle into a RobustHandle. with a more robust mechanism for aborting.

Source

pub fn is_finished(&self) -> bool

Test if the task has finished and is ready to be joined

Source

pub fn abort(&self)

Abort the task, trying to join or co_join an aborted task (if it’s not already completed) will return an error indicating it’s already aborted.

If the task was completed before joining, however, it may not see this abort call. If you always want join to indicate aborted, see RobustHandle

Source

pub fn abort_handle(&self) -> AbortHandle

Return a handle to remotely abort the task

Source

pub fn join(self) -> Result<T>

Block the current thread to join the task

Panics are caught by the runtime, and will be returned as an Err.

Will error if the task was aborted or panicked. If you want to handle the abort, use join_maybe_aborted

§Blocking

Do not use this in an async context, since it will block the runtime, and will panic if the thread is currently driving IO. Use co_join().await instead.

Source

pub async fn co_join(self) -> Result<T>

Wait for the task asynchronously

Panics are caught by the runtime, and will be returned as an Err.

Will error if the task was aborted or panicked. If you want to handle the abort, use co_join_maybe_aborted

Source

pub fn join_maybe_aborted(self) -> Result<Option<T>>

Like join, but returns None if the task was aborted.

Panics are caught by the runtime, and will be returned as an Err.

§Blocking

Do not use this in an async context, since it will block the runtime, and will panic if the thread is currently driving IO. Use co_join_maybe_aborted().await instead.

Source

pub async fn co_join_maybe_aborted(self) -> Result<Option<T>>

Like co_join, but returns None if the task was aborted.

Trait Implementations§

Source§

impl<T> From<Handle<T>> for RobustHandle<T>

Source§

fn from(value: Handle<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> Freeze for Handle<T>
where JoinHandle<T>: Freeze,

§

impl<T> RefUnwindSafe for Handle<T>
where JoinHandle<T>: RefUnwindSafe,

§

impl<T> Send for Handle<T>
where JoinHandle<T>: Send,

§

impl<T> Sync for Handle<T>
where JoinHandle<T>: Sync,

§

impl<T> Unpin for Handle<T>
where JoinHandle<T>: Unpin,

§

impl<T> UnsafeUnpin for Handle<T>
where JoinHandle<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Handle<T>
where JoinHandle<T>: UnwindSafe,

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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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, <T as TryFrom<U>>::Error>

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.