pub struct TaskSet<T> { /* private fields */ }Expand description
A set of spawned tasks, joined as they complete — the seam replacement for
tokio::task::JoinSet.
JoinSet is a fourth spelling of tokio::spawn, and the one no seam
guard caught: JoinSet::spawn calls tokio::spawn internally, so it panics
with “there is no reactor running” on any thread that is not inside a
tokio runtime — which on RTEMS is every callback-band worker. Measured on
target: the CA client’s transport manager died on cbMedium at its first
connect (doc/calink-rtems-design.md §11.1). Naming it here means a call
site can express “spawn a set of tasks and reap them as they finish”
without reaching past the seam.
The three properties call sites depend on, all preserved:
- Concurrency — every member runs independently; joining one does not block the others.
- Pair-by-value —
Self::join_nextyields whichever member finished first, so a task that returns its own key can be matched to its state. - Abort on drop — dropping the set cancels every member that has not
finished, which is the property that distinguishes a
JoinSetfrom a bag of detachedJoinHandles.
Implementations§
Source§impl<T: Send + 'static> TaskSet<T>
impl<T: Send + 'static> TaskSet<T>
Sourcepub fn spawn<F>(&mut self, future: F)
pub fn spawn<F>(&mut self, future: F)
Spawn future into the set — through spawn, so the RTEMS build
lands it on a callback band instead of demanding a tokio runtime.
Sourcepub async fn join_next(&mut self) -> Option<Result<T, TaskJoinError>>
pub async fn join_next(&mut self) -> Option<Result<T, TaskJoinError>>
Wait for the next member to finish and return its result, removing it
from the set. None when the set is empty — matching
JoinSet::join_next, so a select! arm on it goes quiet rather than
spinning once every task has been reaped.
Cancel-safe: the returned future holds no state of its own, so a
select! that drops it loses nothing.