pub struct TaskHandle<T> { /* private fields */ }Expand description
A handle to a task that may be running on another thread.
Implementations§
Source§impl<T> TaskHandle<T>
impl<T> TaskHandle<T>
Sourcepub fn new_pending(id: TaskId) -> (Self, TaskResultSender<T>)
pub fn new_pending(id: TaskId) -> (Self, TaskResultSender<T>)
Creates a new pending task handle and its completion sender.
Sourcepub fn ready(id: TaskId, result: Result<T, TaskError>) -> Self
pub fn ready(id: TaskId, result: Result<T, TaskError>) -> Self
Creates a new task handle from an existing result.
Sourcepub fn new_detached(id: TaskId) -> Self
pub fn new_detached(id: TaskId) -> Self
Sourcepub fn join(self) -> Option<Result<T, TaskError>>
pub fn join(self) -> Option<Result<T, TaskError>>
Waits for the task to complete and returns the result.
§Returns
Some(Ok(result))if the task completed successfullySome(Err(error))if the task failed with an errorNoneif the task was detached
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Checks if the task has finished execution.
§Returns
true if the task has completed (successfully or with error), false if still running
Auto Trait Implementations§
impl<T> !RefUnwindSafe for TaskHandle<T>
impl<T> !UnwindSafe for TaskHandle<T>
impl<T> Freeze for TaskHandle<T>
impl<T> Send for TaskHandle<T>
impl<T> Sync for TaskHandle<T>
impl<T> Unpin for TaskHandle<T>
impl<T> UnsafeUnpin for TaskHandle<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