pub struct TaskGroup {
tasks: Mutex<Vec<TaskHandler>>,
stop_signal: Arc<CondWait>,
executor: Executor,
}
Expand description
TaskGroup A group that contains spawned tasks.
§Example
use std::sync::Arc;
use karyon_core::async_util::{TaskGroup, sleep};
async {
let group = TaskGroup::new();
group.spawn(sleep(std::time::Duration::MAX), |_| async {});
group.cancel().await;
};
Fields§
§tasks: Mutex<Vec<TaskHandler>>
§stop_signal: Arc<CondWait>
§executor: Executor
Implementations§
Source§impl TaskGroup
impl TaskGroup
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new TaskGroup without providing an executor
This will spawn a task onto a global executor (single-threaded by default).
Sourcepub fn with_executor(executor: Executor) -> Self
pub fn with_executor(executor: Executor) -> Self
Creates a new TaskGroup by providing an executor
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