Skip to content

Commit

Permalink
fix(metrics): :impl Atomic<u64> for AtomicU64
Browse files Browse the repository at this point in the history
fix the error when using Gauge<u64, AtomicU64> type,
revert the `impl Atomic<u64> fro AtomicU64` from #105
  • Loading branch information
koushiro committed Feb 28, 2024
1 parent 4eecdc3 commit 359a8e1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/metrics/gauge.rs
Expand Up @@ -187,6 +187,33 @@ impl Atomic<i32> for AtomicI32 {
}
}

#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
impl Atomic<u64> for AtomicU64 {
fn inc(&self) -> u64 {
self.inc_by(1)
}

fn inc_by(&self, v: u64) -> u64 {
self.fetch_add(v, Ordering::Relaxed)
}

fn dec(&self) -> u64 {
self.dec_by(1)
}

fn dec_by(&self, v: u64) -> u64 {
self.fetch_sub(v, Ordering::Relaxed)
}

fn set(&self, v: u64) -> u64 {
self.swap(v, Ordering::Relaxed)
}

fn get(&self) -> u64 {
self.load(Ordering::Relaxed)
}
}

#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
impl Atomic<f64> for AtomicU64 {
fn inc(&self) -> f64 {
Expand Down

0 comments on commit 359a8e1

Please sign in to comment.