pub struct TaskGroup<E> { /* private fields */ }
Expand description
A TaskGroup is used to spawn a collection of tasks. The collection has two properties:
- if any task returns an error or panicks, all tasks are terminated.
- if the
TaskManager
returned byTaskGroup::new
is dropped, all tasks are terminated.
Implementations§
Source§impl<E: Send + 'static> TaskGroup<E>
impl<E: Send + 'static> TaskGroup<E>
pub fn new() -> (Self, TaskManager<E>)
pub fn spawn( &self, name: impl AsRef<str>, f: impl Future<Output = Result<(), E>> + Send + 'static, ) -> impl Future<Output = Result<(), SpawnError>> + '_
pub fn spawn_on( &self, name: impl AsRef<str>, runtime: Handle, f: impl Future<Output = Result<(), E>> + Send + 'static, ) -> impl Future<Output = Result<(), SpawnError>> + '_
pub fn spawn_local( &self, name: impl AsRef<str>, f: impl Future<Output = Result<(), E>> + 'static, ) -> impl Future<Output = Result<(), SpawnError>> + '_
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for TaskGroup<E>
impl<E> !RefUnwindSafe for TaskGroup<E>
impl<E> Send for TaskGroup<E>where
E: Send,
impl<E> Sync for TaskGroup<E>where
E: Send,
impl<E> Unpin for TaskGroup<E>
impl<E> !UnwindSafe for TaskGroup<E>
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