Skip to content

Commit

Permalink
[impl] Relax ordering guarantees for metric updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sadroeck committed Jun 18, 2021
1 parent 5527a19 commit 854894c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions metrics/src/metric_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Counter {
/// Increases the value of the [`Counter`] by a discrete amount
#[inline]
pub(crate) fn increment(&self, val: u64) {
self.0.fetch_add(val, Ordering::SeqCst);
self.0.fetch_add(val, Ordering::Release);
}

/// Read the current state of the [`Counter`]
Expand All @@ -49,19 +49,19 @@ impl DiscreteGauge {
/// Overwrite the value of the [`DiscreteGauge`] to a fixed discrete amount
#[inline]
pub(crate) fn set(&self, val: f64) {
self.0.store(val as u64, Ordering::SeqCst);
self.0.store(val as u64, Ordering::Relaxed);
}

/// Increases the value of the [`DiscreteGauge`] by a discrete amount
#[inline]
pub(crate) fn increase(&self, val: f64) {
self.0.fetch_add(val as u64, Ordering::SeqCst);
self.0.fetch_add(val as u64, Ordering::Release);
}

/// Decreases the value of the [`DiscreteGauge`] by a discrete amount
#[inline]
pub(crate) fn decrease(&self, val: f64) {
self.0.fetch_sub(val as u64, Ordering::SeqCst);
self.0.fetch_sub(val as u64, Ordering::Release);
}

/// Read the current state of the [`DiscreteGauge`]
Expand All @@ -84,7 +84,7 @@ impl Gauge {
/// Overwrite the value of the [`Gauge`] to a fixed real amount
#[inline]
pub(crate) fn set(&self, val: f64) {
self.0.store(val.to_bits(), Ordering::SeqCst);
self.0.store(val.to_bits(), Ordering::Relaxed);
}

/// Increases the value of the [`Gauge`] by a real amount
Expand Down

0 comments on commit 854894c

Please sign in to comment.