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>
impl<T> JoinHandle<T>
Sourcepub fn on_complete<H>(self, complete_hook: H)where
H: OnTaskComplete<T> + 'static,
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.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if the task has been completed successfully
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if the task has been cancelled
Sourcepub fn join<I: IntoCreateIdle>(self, idle: I) -> Result<T, JoinError>
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 withJoinError::AlreadyTaken.Err- the task has been cancelled or the result has already been taken bySelf::try_take.
Sourcepub fn try_take(&self) -> Result<Option<T>, JoinError>
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 withJoinError::AlreadyTaken.Err- the task has been cancelled or the result has already been taken.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more