pub struct EventStore { /* private fields */ }Expand description
Event Store - Centralized storage for memory events
The EventStore is the single source of truth for all memory events in the system. It uses a lock-free SegQueue for recording operations and a RwLock-protected Vec for efficient snapshots.
Key properties:
- Lock-free recording: Uses SegQueue for O(1) append without blocking
- Thread-safe: All operations are safe for concurrent use
- Efficient snapshots: Uses RwLock for fast read access
- Clear-safe: Uses atomic flag to prevent event loss during clear operations
Implementations§
Source§impl EventStore
impl EventStore
Sourcepub fn record(&self, event: MemoryEvent)
pub fn record(&self, event: MemoryEvent)
Record a memory event
This method is lock-free and can be called from any thread without blocking other recording operations.
§Arguments
event- The memory event to record
§Note
If a clear operation is in progress, this method will skip recording the event to prevent data loss. This ensures consistency between the event queue and the count.
Sourcepub fn snapshot(&self) -> Vec<MemoryEvent>
pub fn snapshot(&self) -> Vec<MemoryEvent>
Get all events as a snapshot
Returns a snapshot of all events currently in the store. This method flushes any pending events from the lock-free queue to the cache before returning.
§Returns
A vector containing all events in the store
Trait Implementations§
Source§impl Debug for EventStore
impl Debug for EventStore
Auto Trait Implementations§
impl !Freeze for EventStore
impl !RefUnwindSafe for EventStore
impl Send for EventStore
impl Sync for EventStore
impl Unpin for EventStore
impl UnsafeUnpin for EventStore
impl UnwindSafe for EventStore
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more