pub struct TaskRegistry { /* private fields */ }Expand description
Process-wide registry of in-flight background tasks.
Cloneable, backed by Arc<RwLock<…>>. All methods are safe to call
concurrently.
Implementations§
Source§impl TaskRegistry
impl TaskRegistry
pub fn new() -> Self
Sourcepub async fn register(&self, state: TaskState) -> Arc<TaskState> ⓘ
pub async fn register(&self, state: TaskState) -> Arc<TaskState> ⓘ
Register a new task. Returns a clone of the Arc<TaskState>
so callers can write to its output channel.
Sourcepub async fn stop(&self, id: &TaskId) -> bool
pub async fn stop(&self, id: &TaskId) -> bool
Stop a task by ID. Returns true if a running task was found
and aborted.
Sourcepub async fn drain_output(&self, id: &TaskId) -> usize
pub async fn drain_output(&self, id: &TaskId) -> usize
Drain output for a single task.
Sourcepub async fn append_output(&self, id: &TaskId, line: String) -> bool
pub async fn append_output(&self, id: &TaskId, line: String) -> bool
Append a single output line for a task.
Sourcepub async fn drain_all(&self) -> usize
pub async fn drain_all(&self) -> usize
Drain output for all known tasks. Useful after waking up to propagate new state.
pub async fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for TaskRegistry
impl Clone for TaskRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for TaskRegistry
impl !UnwindSafe for TaskRegistry
impl Freeze for TaskRegistry
impl Send for TaskRegistry
impl Sync for TaskRegistry
impl Unpin for TaskRegistry
impl UnsafeUnpin for TaskRegistry
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Converts this value into a three-state builder argument.
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Converts this value into an optional builder argument.