pub struct ShmRingBuffer { /* private fields */ }Expand description
Thread-safe and process-safe circular ring buffer for zero-copy frame exchange.
Implementations§
Source§impl ShmRingBuffer
impl ShmRingBuffer
Sourcepub fn new(capacity: usize) -> Arc<Self> ⓘ
pub fn new(capacity: usize) -> Arc<Self> ⓘ
Creates a new circular frame buffer with the specified slot capacity (minimum 2).
Sourcepub fn dropped_frames(&self) -> u64
pub fn dropped_frames(&self) -> u64
Number of dropped frames due to consumer backpressure.
Sourcepub fn begin_write(&self) -> usize
pub fn begin_write(&self) -> usize
Acquires a slot for the producer to write a new frame. Returns the target slot index.
Sourcepub fn commit_write(
&self,
slot_idx: usize,
width: u32,
height: u32,
damage_rects: Vec<Rect>,
display_list: DisplayList,
pixel_buffer: Option<Vec<u8>>,
)
pub fn commit_write( &self, slot_idx: usize, width: u32, height: u32, damage_rects: Vec<Rect>, display_list: DisplayList, pixel_buffer: Option<Vec<u8>>, )
Commits a written frame slot, updating its metadata and making it available to the consumer.
Sourcepub fn acquire_latest(&self, last_sequence: u64) -> Option<(u64, ShmFrameSlot)>
pub fn acquire_latest(&self, last_sequence: u64) -> Option<(u64, ShmFrameSlot)>
Acquires the most recent committed frame for zero-copy read access by the compositor.
Returns a guard or cloned snapshot of the frame if a newer frame exists than last_sequence.
Sourcepub fn has_new_frame(&self, last_sequence: u64) -> bool
pub fn has_new_frame(&self, last_sequence: u64) -> bool
Checks if a newer frame is available than last_sequence without reading the full slot.
Auto Trait Implementations§
impl !Freeze for ShmRingBuffer
impl Forget for ShmRingBuffer
impl Move for ShmRingBuffer
impl RefUnwindSafe for ShmRingBuffer
impl Send for ShmRingBuffer
impl Sync for ShmRingBuffer
impl Unpin for ShmRingBuffer
impl UnsafeUnpin for ShmRingBuffer
impl UnwindSafe for ShmRingBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more