Skip to main content

TaskCompletion

Struct TaskCompletion 

Source
pub struct TaskCompletion<R, E> { /* private fields */ }
Expand description

Completion endpoint owned by a task runner.

This low-level endpoint is exposed so custom executor services built on top of qubit-executor can wire their own scheduling and cancellation hooks while still returning the standard crate::TaskHandle. Normal callers should use crate::TaskHandle and executor/service submission methods instead.

Implementations§

Source§

impl<R, E> TaskCompletion<R, E>

Source

pub fn start(&self) -> bool

Marks the task as started if it was not cancelled first.

§Returns

true if the runner should execute the task, or false if the task was already completed through cancellation.

Source

pub fn complete(&self, result: TaskResult<R, E>)

Completes the task with its final result.

If another path has already completed the task, this result is ignored.

§Parameters
  • result - Final task result to publish if the task is not already completed.
Source

pub fn start_and_complete<F>(&self, task: F) -> bool
where F: FnOnce() -> TaskResult<R, E>,

Starts the task and completes it with a lazily produced result.

The supplied closure is executed only if this completion endpoint wins the start race. If the handle was cancelled first, the closure is not called and the existing cancellation result is preserved.

§Parameters
  • task - Closure that runs the accepted task and returns its final result.
§Returns

true if the closure was executed and its result was published, or false if the task had already been completed by cancellation.

Source

pub fn cancel(&self) -> bool

Cancels the task if it has not started yet.

§Returns

true if this call published a cancellation result, or false if the task was already started or completed.

Trait Implementations§

Source§

impl<R, E> Clone for TaskCompletion<R, E>

Source§

fn clone(&self) -> Self

Clones the completion endpoint for mutually exclusive finish paths.

§Returns

A completion endpoint sharing the same task state.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<R, E> Freeze for TaskCompletion<R, E>

§

impl<R, E> RefUnwindSafe for TaskCompletion<R, E>

§

impl<R, E> Send for TaskCompletion<R, E>
where R: Send, E: Send,

§

impl<R, E> Sync for TaskCompletion<R, E>
where R: Send, E: Send,

§

impl<R, E> Unpin for TaskCompletion<R, E>

§

impl<R, E> UnsafeUnpin for TaskCompletion<R, E>

§

impl<R, E> UnwindSafe for TaskCompletion<R, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.