Expand description
Monitors supervise a set of related tasks, aborting them on any failure.
let (group, handle) = monitor::group();
let (flag, guard) = flag::guarded();
group.spawn(async move {
flag.await;
Result::<(), ()>::Err(())
});
group.spawn(async move {
guard.signal();
Result::<(), ()>::Ok(())
});
assert_eq!(handle.await, monitor::Status::Failed);
Structs§
- Group
- A group of tasks that share a common fate. Any tasks that are spawned onto the group will be aborted if any task fails or if the group is aborted.
- Handle
- A handle to a monitored task group. Handles may be awaited to wait for the completion of the group (failure or abortion).
Enums§
- Status
- The status of a group. Groups start out in
Status::Running
and transition exactly zero or one time to eitherStatus::Failed
orStatus::Aborted
.
Functions§
- group
- Create a new monitored group and handle. The group is aborted if either group or its handle are dropped.