Skip to main content

TaskHandle

Struct TaskHandle 

Source
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>

Source

pub fn new_pending(id: TaskId) -> (TaskHandle<T>, TaskResultSender<T>)

Creates a new pending task handle and its completion sender.

Source

pub fn ready(id: TaskId, result: Result<T, TaskError>) -> TaskHandle<T>

Creates a new task handle from an existing result.

Source

pub fn new_detached(id: TaskId) -> TaskHandle<T>

Creates a new detached task handle (no result channel).

§Arguments
  • id - The unique identifier for this task
§Returns

A new detached task handle instance

Source

pub fn id(&self) -> TaskId

Returns the task ID.

§Returns

The unique identifier for this task

Source

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 successfully
  • Some(Err(error)) if the task failed with an error
  • None if the task was detached
Source

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>
where Option<Arc<TaskResultSlot<T>>>: Freeze,

§

impl<T> Send for TaskHandle<T>
where Option<Arc<TaskResultSlot<T>>>: Send,

§

impl<T> Sync for TaskHandle<T>
where Option<Arc<TaskResultSlot<T>>>: Sync,

§

impl<T> Unpin for TaskHandle<T>
where Option<Arc<TaskResultSlot<T>>>: Unpin,

§

impl<T> UnsafeUnpin for TaskHandle<T>
where Option<Arc<TaskResultSlot<T>>>: UnsafeUnpin,

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.