pub struct WindowedCounterGroup { /* private fields */ }Expand description
A CounterGroup restricted to torn-safe windowed access.
Holds an inner base CounterGroup and exposes only the windowed
writer/reader (set_with_window/load_with_window), the lock-free
read accessors, and metadata — not the base group’s lock-free mutators
(set/add/increment). Because no lock-free mutator is reachable, a
windowless write is unrepresentable and torn-safety is enforced by the
type. The window store and the atomic (value, window) pairing live on the
inner base group (Phase-1 GroupWindows lock); this wrapper only narrows
the API.
Implementations§
Source§impl WindowedCounterGroup
impl WindowedCounterGroup
Sourcepub const fn new(entries: usize) -> Self
pub const fn new(entries: usize) -> Self
Create a windowed counter group with the given number of entries.
Sourcepub fn set_with_window(&self, idx: usize, value: u64, window: Window) -> bool
pub fn set_with_window(&self, idx: usize, value: u64, window: Window) -> bool
Set the counter at idx to value and record its acquisition window
as a torn-safe pair. Returns false if idx is out of bounds.
Sourcepub fn load_with_window(&self, idx: usize) -> (Option<u64>, Option<Window>)
pub fn load_with_window(&self, idx: usize) -> (Option<u64>, Option<Window>)
Load the counter at idx and its acquisition window as a torn-safe
pair. Returns (None, None) if idx is out of bounds.
Sourcepub fn set_metadata(&self, idx: usize, metadata: HashMap<String, String>)
pub fn set_metadata(&self, idx: usize, metadata: HashMap<String, String>)
Set metadata for the entry at idx.
Sourcepub fn insert_metadata(&self, idx: usize, key: String, value: String)
pub fn insert_metadata(&self, idx: usize, key: String, value: String)
Set a single metadata key-value pair for the entry at idx.
Sourcepub fn load_metadata(&self, idx: usize) -> Option<HashMap<String, String>>
pub fn load_metadata(&self, idx: usize) -> Option<HashMap<String, String>>
Load metadata for the entry at idx.
Sourcepub fn metadata_snapshot(&self) -> Vec<(usize, HashMap<String, String>)>
pub fn metadata_snapshot(&self) -> Vec<(usize, HashMap<String, String>)>
Snapshot all metadata.
Sourcepub fn clear_metadata(&self, idx: usize)
pub fn clear_metadata(&self, idx: usize)
Remove metadata for the entry at idx.
Trait Implementations§
Source§impl Metric for WindowedCounterGroup
impl Metric for WindowedCounterGroup
Source§fn as_any(&self) -> Option<&dyn Any>
fn as_any(&self) -> Option<&dyn Any>
Any instance. This is meant to allow
custom processing for known metric types.