pub struct GenerationCounter { /* private fields */ }Expand description
Atomic generation counter for tracking buffer lifecycle events.
This counter provides thread-safe tracking of buffer state changes throughout its lifecycle. Each buffer operation (allocation, use, reuse) can increment the generation to help with debugging buffer lifecycle issues and detecting use-after-free scenarios in development builds.
The counter uses relaxed atomic ordering since exact ordering of generation updates across threads is not critical for its debugging purposes.
§Thread Safety
All operations on GenerationCounter are thread-safe and can be called
concurrently from multiple threads.
§Examples
use safer_ring::buffer::GenerationCounter;
let counter = GenerationCounter::new();
assert_eq!(counter.get(), 0);
counter.increment();
assert_eq!(counter.get(), 1);
counter.set(42);
assert_eq!(counter.get(), 42);Implementations§
Trait Implementations§
Source§impl Clone for GenerationCounter
impl Clone for GenerationCounter
Source§impl Debug for GenerationCounter
impl Debug for GenerationCounter
Auto Trait Implementations§
impl !Freeze for GenerationCounter
impl RefUnwindSafe for GenerationCounter
impl Send for GenerationCounter
impl Sync for GenerationCounter
impl Unpin for GenerationCounter
impl UnwindSafe for GenerationCounter
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