pub struct PerfEventArrayBuffer<T> { /* private fields */ }Expand description
A ring buffer that can receive events from eBPF programs.
PerfEventArrayBuffer is a ring buffer that can receive events from eBPF
programs that use bpf_perf_event_output(). It’s returned by PerfEventArray::open.
See the PerfEventArray documentation for an overview of how to use
perf buffers.
Implementations§
Source§impl<T: BorrowMut<MapData>> PerfEventArrayBuffer<T>
impl<T: BorrowMut<MapData>> PerfEventArrayBuffer<T>
Sourcepub fn readable(&self) -> bool
pub fn readable(&self) -> bool
Returns true if the buffer contains events that haven’t been read.
Sourcepub fn try_fold<B, C, F>(&mut self, init: C, f: F) -> ControlFlow<B, C>
pub fn try_fold<B, C, F>(&mut self, init: C, f: F) -> ControlFlow<B, C>
Processes events available in the buffer with f.
For each available event, f receives the accumulator and event:
ControlFlow::Continue(next)keeps draining withnext.ControlFlow::Break(break_value)stops early and returnsbreak_value.
If the buffer is fully drained, returns ControlFlow::Continue
containing the final accumulator.
The slices in PerfEvent::Sample are borrowed directly from the perf
ring buffer; the borrow is bounded by the closure invocation. The
kernel-visible data_tail is advanced once at the end of the call,
amortizing the SeqCst store across the drain.
Sourcepub fn fold<C, F>(&mut self, init: C, f: F) -> C
pub fn fold<C, F>(&mut self, init: C, f: F) -> C
Processes events available in the buffer with f.
For each available event, f receives the accumulator and event, and
returns the next accumulator. Unlike PerfEventArrayBuffer::try_fold,
this function cannot short-circuit: it always processes events until the
buffer is fully drained, then returns the final accumulator.