Skip to main content

TraceBufferHandle

Struct TraceBufferHandle 

Source
pub struct TraceBufferHandle { /* private fields */ }
Expand description

Thread-safe handle for sharing a trace buffer across tasks.

This wraps a TraceBuffer in a mutex and adds a monotonically increasing sequence counter for event ordering.

Implementations§

Source§

impl TraceBufferHandle

Source

pub fn new(capacity: usize) -> Self

Creates a new trace buffer handle with the given capacity.

Source

pub fn next_seq(&self) -> u64

Allocates and returns the next trace sequence number.

Callers that are about to push onto this shared handle should prefer record_event so sequence allocation and buffer insertion cannot be interleaved by another producer.

Source

pub fn push_event(&self, event: TraceEvent)

Pushes a pre-built trace event into the buffer.

This preserves the event’s existing sequence number and advances the handle’s allocator past it. The latter matters when importing a replay prefix before recording new events. Callers that need a fresh sequence number from this handle should prefer record_event.

Source

pub fn record_event<F>(&self, build: F)
where F: FnOnce(u64) -> TraceEvent,

Builds and pushes a trace event while holding the buffer lock.

This keeps sequence allocation and insertion serialized so concurrent producers cannot insert seq N + 1 ahead of seq N.

The builder runs while the buffer lock is held, so it should stay lightweight and must not re-enter the same trace handle.

Source

pub fn snapshot(&self) -> Vec<TraceEvent>

Returns a snapshot of buffered events in seq order (oldest to newest).

br-asupersync-xh4efw: insertion order and seq order can differ — spawn-effect events allocate their seq at admission (via next_seq) but are pushed at deferred dispatch, after later-sequenced events may already be in the ring. The snapshot sorts by seq so consumers observe the per-task causal contract (a task’s Spawn seq precedes its Complete seq). Seqs may have gaps (an allocated-but-abandoned spawn effect never pushes); seq is an ordering key, not a dense index.

Source

pub fn len(&self) -> usize

Returns the current number of buffered events.

Source

pub fn capacity(&self) -> usize

Returns the configured buffer capacity.

Source

pub fn total_pushed(&self) -> u64

Returns the total number of events pushed since creation.

This includes events that may no longer be present in the ring buffer due to capacity eviction.

Source

pub fn is_empty(&self) -> bool

Returns true if the buffer is empty.

Trait Implementations§

Source§

impl Clone for TraceBufferHandle

Source§

fn clone(&self) -> TraceBufferHandle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TraceBufferHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V