pub struct TaskGroup { /* private fields */ }
Expand description
Allows the user to spawn multiple Tasks and await them as a unit.
Tasks can be added to this group using [TaskGroup::add
].
All pending tasks in the group can be awaited using TaskGroup::join
.
New code should prefer to use Scope
instead.
Implementations§
Source§impl TaskGroup
impl TaskGroup
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new TaskGroup.
The TaskGroup can be used to await an arbitrary number of Tasks and may consume an arbitrary amount of memory.
Sourcepub fn spawn(&mut self, future: impl Future<Output = ()> + Send + 'static)
pub fn spawn(&mut self, future: impl Future<Output = ()> + Send + 'static)
Spawns a new task in this TaskGroup.
To add a future that is not Send
to this TaskGroup, use TaskGroup::local
.
§Panics
spawn
may panic if not called in the context of an executor (e.g.
within a call to run
or run_singlethreaded
).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TaskGroup
impl !RefUnwindSafe for TaskGroup
impl Send for TaskGroup
impl Sync for TaskGroup
impl Unpin for TaskGroup
impl !UnwindSafe for TaskGroup
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