#[repr(align(64))]pub struct Gauge { /* private fields */ }
Expand description
Ultra-fast atomic gauge for f64 values
Uses IEEE 754 bit manipulation for atomic operations on floating-point values. Cache-line aligned to prevent false sharing.
Implementations§
Source§impl Gauge
impl Gauge
Sourcepub fn with_value(initial: f64) -> Self
pub fn with_value(initial: f64) -> Self
Create gauge with initial value
Sourcepub fn set(&self, value: f64)
pub fn set(&self, value: f64)
Set gauge value - THE FASTEST PATH
This is optimized for maximum speed:
- Convert f64 to IEEE 754 bits
- Single atomic store instruction
- Relaxed memory ordering for speed
- Inlined for zero function call overhead
Sourcepub fn add(&self, delta: f64)
pub fn add(&self, delta: f64)
Add to current value - atomic read-modify-write loop
Uses compare-and-swap loop for lock-free addition
Sourcepub fn compare_and_swap(&self, expected: f64, new: f64) -> Result<f64, f64>
pub fn compare_and_swap(&self, expected: f64, new: f64) -> Result<f64, f64>
Atomic compare-and-swap
Returns Ok(previous_value) if successful, Err(current_value) if failed
Sourcepub fn update_ema(&self, sample: f64, alpha: f64)
pub fn update_ema(&self, sample: f64, alpha: f64)
Exponential moving average update
new_value = alpha * sample + (1 - alpha) * old_value
Sourcepub fn stats(&self) -> GaugeStats
pub fn stats(&self) -> GaugeStats
Get comprehensive statistics
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Check if value is positive
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Check if value is negative
Trait Implementations§
impl Send for Gauge
impl Sync for Gauge
Auto Trait Implementations§
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