JoinHandle

Struct JoinHandle 

Source
pub struct JoinHandle<T> { /* private fields */ }
Expand description

Returned by Runtime::spawn to monitor a Task and poll its output.

Implementations§

Source§

impl<T> JoinHandle<T>

Source

pub fn on_complete<H>(self, complete_hook: H)
where H: OnTaskComplete<T> + 'static,

Set the OnTaskComplete hook that will be called when the task has been complete. If the task was already complete, the hook will be called immediately from the caller’s thread.

Source

pub fn is_active(&self) -> bool

Check if the task is still running

Source

pub fn is_complete(&self) -> bool

Check if the task has been completed successfully

Source

pub fn is_cancelled(&self) -> bool

Check if the task has been cancelled

Source

pub fn join<I: IntoCreateIdle>(self, idle: I) -> Result<T, JoinError>

Join the task, blocking until it is complete or cancelled.

§Return Values
  • None - task is still running and an output is not yet available.
  • Ok - task has been completed and the output has been taken. Subsequent calls to take will fail with JoinError::AlreadyTaken.
  • Err - the task has been cancelled or the result has already been taken by Self::try_take.
Source

pub fn try_take(&self) -> Result<Option<T>, JoinError>

Try to take the Task output.

§Return Values
  • None - task is still running and an output is not yet available.
  • Ok - task has been completed and the output has been taken. Subsequent calls to take will fail with JoinError::AlreadyTaken.
  • Err - the task has been cancelled or the result has already been taken.
Source

pub fn cancel(&self)

Cancel the current task

Trait Implementations§

Source§

impl<T> Drop for JoinHandle<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for JoinHandle<T>

§

impl<T> RefUnwindSafe for JoinHandle<T>

§

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

§

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

§

impl<T> Unpin for JoinHandle<T>

§

impl<T> UnwindSafe for JoinHandle<T>

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 = Infallible

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.