pub trait MailboxDepthObserver:
Send
+ Sync
+ 'static {
// Required method
fn on_depth_change(&self, queued_messages: usize);
}Expand description
Observer notified whenever a Mailbox implementation observes a
change in its queue depth.
Installed on a mailbox via Mailbox::set_depth_observer. Backends
that cannot cheaply report depth on every enqueue may return false
from that method, in which case consumers must fall back to periodic
polling via Mailbox::status.
The observer is called synchronously from the enqueue code path;
implementations should therefore keep their work short (typically a
bounded try_send into a channel). Implementations must not block
the enqueue path and must tolerate missed notifications.
Required Methods§
Sourcefn on_depth_change(&self, queued_messages: usize)
fn on_depth_change(&self, queued_messages: usize)
Called after an enqueue completes, carrying the post-enqueue queued-message count.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".