Skip to content

Commit

Permalink
metrics: add fetch_add for AtomicU64 (#4453)
Browse files Browse the repository at this point in the history
  • Loading branch information
asonix authored Jan 31, 2022
1 parent 2cee1db commit 77468ae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tokio/src/loom/std/atomic_u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ cfg_not_has_atomic_u64! {
*self.inner.lock() = val;
}

pub(crate) fn fetch_add(&self, val: u64, _: Ordering) -> u64 {
let mut lock = self.inner.lock();
let prev = *lock;
*lock = prev + val;
prev
}

pub(crate) fn fetch_or(&self, val: u64, _: Ordering) -> u64 {
let mut lock = self.inner.lock();
let prev = *lock;
Expand Down

0 comments on commit 77468ae

Please sign in to comment.