pub struct TaskScope {
pub name: Rc<str>,
pub tasks: RefCell<Vec<Rc<Task>>>,
/* private fields */
}Expand description
The task scope scope name { ... } binds.
The scope owns every task spawned into it, which is what lets leaving the scope wait for or cancel its children.
Fields§
§name: Rc<str>The name the scope is bound to, for diagnostics.
tasks: RefCell<Vec<Rc<Task>>>Child tasks in spawn order.
Implementations§
Source§impl TaskScope
impl TaskScope
pub fn new(name: Rc<str>) -> Rc<TaskScope>
Sourcepub fn adopt(&self, task: Rc<Task>) -> Rc<Task>
pub fn adopt(&self, task: Rc<Task>) -> Rc<Task>
Adopts a task that is already running, and returns its handle.
Sourcepub fn next_position(&self) -> usize
pub fn next_position(&self) -> usize
The position the next task spawned into this scope will have.
Sourcepub fn task_at(&self, index: usize) -> Option<Rc<Task>>
pub fn task_at(&self, index: usize) -> Option<Rc<Task>>
The task at index in spawn order, if the scope has one.
Sourcepub fn cancel_running(&self)
pub fn cancel_running(&self)
Asks every child that is still running to stop.
pub fn is_closed(&self) -> bool
pub fn close(&self)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TaskScope
impl !RefUnwindSafe for TaskScope
impl !Send for TaskScope
impl !Sync for TaskScope
impl !UnwindSafe for TaskScope
impl Unpin for TaskScope
impl UnsafeUnpin for TaskScope
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