Skip to main content

TaskRunner

Struct TaskRunner 

Source
pub struct TaskRunner<C> { /* private fields */ }
Expand description

Runner that executes a callable task with standard task-handle semantics.

TaskRunner owns the accepted callable, converts task failures and panics into TaskExecutionError, and can publish the final result through a TaskSlot endpoint.

Implementations§

Source§

impl<C> TaskRunner<C>

Source

pub const fn new(task: C) -> Self

Creates a runner for the supplied callable task.

§Parameters
  • task - Callable task to execute later.
§Returns

A runner that owns the callable task.

Source

pub fn call<R, E>(self) -> TaskResult<R, E>
where C: Callable<R, E>,

Runs the callable and converts task failure and panic into a handle result.

§Returns

Ok(R) if the task succeeds. If the task returns Err(E) or panics, the corresponding TaskExecutionError is returned.

Source

pub fn run<R, E>(self, slot: TaskSlot<R, E>) -> bool
where C: Callable<R, E>,

Runs this task through a task completion endpoint.

§Parameters
  • completion - Completion endpoint that publishes the final result.
§Returns

true if the task started and its result was published, or false if the completion endpoint had already been completed before the runner started.

Source

pub fn run_detached<R, E>(self)
where C: Callable<R, E>,

Runs this task and discards its final result.

This is intended for detached runnable submissions whose caller only observes acceptance. The callable is still wrapped in panic conversion, but success, task failure, and panic results are intentionally dropped.

Auto Trait Implementations§

§

impl<C> Freeze for TaskRunner<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for TaskRunner<C>
where C: RefUnwindSafe,

§

impl<C> Send for TaskRunner<C>
where C: Send,

§

impl<C> Sync for TaskRunner<C>
where C: Sync,

§

impl<C> Unpin for TaskRunner<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for TaskRunner<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for TaskRunner<C>
where C: UnwindSafe,

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> DropFlavorWrapper<T> for T

Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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> IntoResult<T> for T

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.