Skip to main content

TaskEndpointPair

Struct TaskEndpointPair 

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

One-shot pair of endpoints for a task submission.

A pair owns the shared task completion endpoint and the result receiver until it is split into caller-facing and runner-facing endpoints. Pairs created with Self::new do not install a lifecycle hook, avoiding the allocation and dynamic dispatch cost of a no-op hook on the default path.

Custom executors using this SPI should call TaskSlot::accept or the crate-internal handle acceptance path only after submission has succeeded. Dropping a runner slot before acceptance releases result waiters with Dropped but does not emit hook lifecycle events. Once a service has accepted a task, it should call TaskSlot::cancel_unstarted rather than dropping the slot when it intentionally removes unstarted work, so result handles observe cancellation instead of an abandoned runner endpoint.

Implementations§

Source§

impl<R, E> TaskEndpointPair<R, E>

Source

pub fn new() -> Self

Creates a new unsplit task completion pair without lifecycle hooks.

§Returns

A pair that can be split once into its handle and completion endpoints.

Source

pub fn with_hook(hook: Arc<dyn TaskHook>) -> Self

Creates a new unsplit task completion pair with a lifecycle hook.

§Parameters
  • hook - Hook notified about this task’s lifecycle.
§Returns

A pair that can be split once into its handle and runner slot.

Source

pub fn into_parts(self) -> (TaskHandle<R, E>, TaskSlot<R, E>)

Splits this pair into a result handle and completion endpoint.

§Returns

A TaskHandle for the caller and a TaskSlot for the runner.

Source

pub fn into_tracked_parts(self) -> (TrackedTask<R, E>, TaskSlot<R, E>)

Splits this pair into a tracked result handle and completion endpoint.

§Returns

A TrackedTask for the caller and a TaskSlot for the runner.

Trait Implementations§

Source§

impl<R, E> Default for TaskEndpointPair<R, E>

Source§

fn default() -> Self

Creates a new unsplit task completion pair.

Auto Trait Implementations§

§

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

§

impl<R, E> !RefUnwindSafe for TaskEndpointPair<R, E>

§

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

§

impl<R, E> !Sync for TaskEndpointPair<R, E>

§

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

§

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

§

impl<R, E> !UnwindSafe for TaskEndpointPair<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> 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.