Struct muse_reactor::TaskHandle
source · pub struct TaskHandle { /* private fields */ }Expand description
A handle to a task spawned in a reactor.
Implementations§
source§impl TaskHandle
impl TaskHandle
sourcepub fn join(&self) -> Result<RootedValue, TaskError>
pub fn join(&self) -> Result<RootedValue, TaskError>
Blocks the current thread until the task is finished.
This function is not safe to execute from async code. TaskHandle
implements Future and can be awaited.
sourcepub fn try_join(&self) -> Option<Result<RootedValue, TaskError>>
pub fn try_join(&self) -> Option<Result<RootedValue, TaskError>>
Checks if the task has executed, returning the result if it has.
This function returns None if the task is pending execution or still
executing.
This function is safe to call from both async and non-async code.
sourcepub fn join_until(
&self,
deadline: Instant,
) -> Option<Result<RootedValue, TaskError>>
pub fn join_until( &self, deadline: Instant, ) -> Option<Result<RootedValue, TaskError>>
Blocks the current thread until the task is finished or deadline has
passed.
This function is not safe to execute from async code. TaskHandle
implements Future and can be awaited, and the future can be
cancelled using the async runtime’s timeout functionality.
sourcepub fn join_for(
&self,
duration: Duration,
) -> Option<Result<RootedValue, TaskError>>
pub fn join_for( &self, duration: Duration, ) -> Option<Result<RootedValue, TaskError>>
Blocks the current thread until the task is finished or duration has
elapsed.
This function is not safe to execute from async code. TaskHandle
implements Future and can be awaited, and the future can be
cancelled using the async runtime’s timeout functionality.
sourcepub fn cancel(&self)
pub fn cancel(&self)
Cancels the task if it is still running.
Joining the task will return TaskError::Cancelled if the task was
successfully cancelled.