pub struct TaskMap<T> { /* private fields */ }Expand description
A set of named tasks to run concurrently.
T is the success result type — all tasks in a TaskMap produce the
same T. For heterogeneous batches, use tokio::join! directly.
Implementations§
Source§impl<T> TaskMap<T>
impl<T> TaskMap<T>
Sourcepub fn insert<F, Fut, E>(self, name: &'static str, task: F) -> Self
pub fn insert<F, Fut, E>(self, name: &'static str, task: F) -> Self
Insert a named task into the map.
The closure receives the active CancellationToken and must return
a future producing Result<T, E> where E can be boxed into a
std::error::Error.
§Duplicate names
Backed by BTreeMap::insert — calling insert twice with the
same name silently overwrites the earlier task (“last write
wins”). If you need duplicate-name detection, check .len()
before/after the second insert or use distinct names.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for TaskMap<T>
impl<T> !Sync for TaskMap<T>
impl<T> !UnwindSafe for TaskMap<T>
impl<T> Freeze for TaskMap<T>
impl<T> Send for TaskMap<T>
impl<T> Unpin for TaskMap<T>
impl<T> UnsafeUnpin for TaskMap<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