pub struct Executor<T> { /* private fields */ }Expand description
Fail-fast executor. Constructed by execute_concurrently.
On the first task error: cancels the rest and returns Error::TaskFailed.
Implementations§
Source§impl<T> Executor<T>where
T: Send + 'static,
impl<T> Executor<T>where
T: Send + 'static,
Sourcepub fn with_cancellation(self, token: CancellationToken) -> Self
pub fn with_cancellation(self, token: CancellationToken) -> Self
Attach a cancellation token. Cancelling it requests all running tasks to stop.
§Cooperative cancellation
Each task receives the token via the closure argument and is
responsible for .cancelled().await-ing it. Tasks that ignore
the token will not be interrupted — JoinSet::shutdown aborts
their JoinHandles, but a CPU-bound task that never yields cannot
be preempted. Design tasks to check the token at await points.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Apply an overall timeout. If the timeout elapses, Error::Timeout
is returned and the internal cancellation token is signalled so
remaining tasks observe cancellation. Tasks that ignore the token
continue running until they yield (see Self::with_cancellation).
Sourcepub fn with_partial_results(self) -> PartialExecutor<T>
pub fn with_partial_results(self) -> PartialExecutor<T>
Switch to partial-results mode: every task is awaited; each task’s
Result appears in the returned PartialResults map.
The outer Result still reports infrastructure errors (Error::Timeout,
Error::Cancelled, Error::Join).