pub struct TaskSlot<R, E> { /* private fields */ }Expand description
Runner-side slot for one task submission.
This low-level endpoint is exposed so custom executor services built on top
of qubit-executor can wire their own scheduling while still returning the
standard crate::TaskHandle. Executor implementations should call
Self::accept only after submission succeeds; this arms lifecycle hook
reporting for later start and finish events. Normal callers should use
crate::TaskHandle and executor/service submission methods instead.
Dropping an accepted slot reports crate::TaskExecutionError::Dropped
because it means the runner endpoint was abandoned without making an
explicit terminal decision. Executor services that intentionally discard
accepted work before it starts, such as during
crate::ExecutorService::stop, should call Self::cancel_unstarted so
callers observe crate::TaskExecutionError::Cancelled instead.
Implementations§
Source§impl<R, E> TaskSlot<R, E>
impl<R, E> TaskSlot<R, E>
Sourcepub fn accept(&self)
pub fn accept(&self)
Marks this runner endpoint as accepted and arms lifecycle hook reporting.
Calling this method emits on_accepted before any later on_started or
on_finished event for the same task. Executor implementations must call
it only after submission has succeeded. Dropping a slot before acceptance
still releases result waiters with Dropped, but does not emit lifecycle
hook events for a task that was rejected before acceptance.
Sourcepub fn cancel_unstarted(self) -> bool
pub fn cancel_unstarted(self) -> bool
Cancels this accepted runner endpoint before it starts running.
This method is the runner-side service-provider API for an executor or
executor service that intentionally removes queued, scheduled, or other
unstarted accepted work. It publishes
crate::TaskExecutionError::Cancelled when this slot wins the
pending-task terminal-state race. The slot is consumed to make the
explicit cancellation decision the final runner-side action.
If the slot has already been accepted, successful cancellation emits the
finished lifecycle hook with crate::TaskStatus::Cancelled. If it has
not been accepted, cancellation still releases result waiters but does
not emit lifecycle hook events.
§Returns
true if this call moved the task from pending to cancelled, or false
if another path had already started or completed the task.