pub struct ScopedJoinSet<'scope, T>where
T: 'static,{ /* private fields */ }Expand description
A scoped wrapper around tokio::task::JoinSet for dynamically spawning
and awaiting multiple asynchronous tasks.
ScopedJoinSet allows you to spawn futures that are bound to a specific lifetime 'scope,
ensuring all tasks outlive the scope in which they are spawned. Unlike a standard
JoinSet, this structure internally tracks uniquely-owned pinned futures via FutureHolder,
while exposing a weak reference (WeakFuture) for safe polling.
§Features
- Scoped Futures: Ensures futures cannot outlive the provided
'scope. - Dynamic Spawning: Tasks can be spawned dynamically at runtime.
- Cancellation Safe:
join_next()is cancellation safe; tasks remain in the set until they complete and are awaited. - Automatic Abort: Dropping a
FutureHolderaborts its associated task.
§Safety
- Each spawned task has exactly one
FutureHolder(owning thePin<Box>of the future) and oneWeakFuture(polling handle). FutureHoldertracks whether the future is alive using anAtomicBool.
Implementations§
Trait Implementations§
Source§impl<'scope, T> Default for ScopedJoinSet<'scope, T>where
T: 'static + Default,
impl<'scope, T> Default for ScopedJoinSet<'scope, T>where
T: 'static + Default,
Source§fn default() -> ScopedJoinSet<'scope, T>
fn default() -> ScopedJoinSet<'scope, T>
Returns the “default value” for a type. Read more
impl<'scope, T> Send for ScopedJoinSet<'scope, T>
Auto Trait Implementations§
impl<'scope, T> Freeze for ScopedJoinSet<'scope, T>
impl<'scope, T> !RefUnwindSafe for ScopedJoinSet<'scope, T>
impl<'scope, T> !Sync for ScopedJoinSet<'scope, T>
impl<'scope, T> Unpin for ScopedJoinSet<'scope, T>
impl<'scope, T> !UnwindSafe for ScopedJoinSet<'scope, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more