Skip to main content

Trace

Trait Trace 

pub trait Trace: Send + Sync {
    // Required methods
    fn add_trace_sink(
        &self,
        sink: Arc<dyn Fn(&TraceEvent) + Sync + Send>,
    ) -> Observing;
    fn observers(&self) -> usize;
}
Expand description

A capability of a bus (BusTrace::trace): every emit, listener run, ask and drain reported to the sinks observing it, as it happens.

What an implementation promises:

  • With no sink observing, nothing is built or recorded: an emit costs at most a relaxed atomic load more.
  • Each event goes to every sink observing when it is made, once, on the thread that made it, with a capture number greater than every number given before by the same bus (TraceEvent::capture).
  • Events a sink causes on its own thread while it runs (a sink that emits) are not reported: a sink never hears itself.
  • A sink that panics is ignored; the emit goes on.
  • Dropping the Observing guard removes its sink: once the drop returns, the sink is called no more by this thread, and Trace::observers counts it no more.

Required Methods§

fn add_trace_sink( &self, sink: Arc<dyn Fn(&TraceEvent) + Sync + Send>, ) -> Observing

Adds a sink; it observes until the guard is dropped.

fn observers(&self) -> usize

How many sinks observe now: zero when the tap is off.

Implementations§

§

impl<'a> dyn Trace + 'a

pub fn observe( &self, sink: impl Fn(&TraceEvent) + Send + Sync + 'static, ) -> Observing

Observes the bus with sink until the guard is dropped (Trace::add_trace_sink).

Implementors§

§

impl Trace for Kernel