Skip to main content

TaskObserver

Trait TaskObserver 

Source
pub trait TaskObserver:
    Send
    + Sync
    + Debug {
    // Required method
    fn on_task_event(&self, event: &TaskEvent);
}
Expand description

Observer notified of every task status transition in a TaskManager.

Implementations must not block: the observer is called synchronously on the thread that performed the transition. To do async work (such as sending a notification), enqueue the event and drain it elsewhere.

The store lock is not held when this is called, so an implementation may call back into the same TaskManager without deadlocking.

No ordering guarantee. Each event is built under the lock and delivered after it is released, so two threads transitioning the same task can deliver out of order — a consumer may see the newer status first. That is acceptable for the notification this drives, which the spec makes advisory, but a consumer that needs authoritative state must read it from the store.

Required Methods§

Source

fn on_task_event(&self, event: &TaskEvent)

Called after a task’s status changed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§