Skip to content

Commit

Permalink
CR Feedback: replace cfg_rt with a dead code attr
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoh committed Jun 6, 2024
1 parent d79b7b6 commit 0b5a1cf
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions tokio/src/util/metric_atomics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,30 @@ impl MetricAtomicU64 {
}
}

cfg_rt! {
/// `AtomicUsize` for use in metrics.
///
/// This exposes simplified APIs for use in metrics & uses `std::sync` instead of Loom to avoid polluting loom logs with metric information.
#[derive(Debug, Default)]
pub(crate) struct MetricAtomicUsize {
value: std::sync::atomic::AtomicUsize,
}
#[cfg_attr(not(all(tokio_unstable, feature = "rt")), allow(dead_code))]
/// `AtomicUsize` for use in metrics.
///
/// This exposes simplified APIs for use in metrics & uses `std::sync` instead of Loom to avoid polluting loom logs with metric information.
#[derive(Debug, Default)]
pub(crate) struct MetricAtomicUsize {
value: std::sync::atomic::AtomicUsize,
}

#[cfg_attr(not(tokio_unstable), allow(dead_code))]
impl MetricAtomicUsize {
pub(crate) fn load(&self, ordering: Ordering) -> usize {
self.value.load(ordering)
}
#[cfg_attr(not(all(tokio_unstable, feature = "rt")), allow(dead_code))]
impl MetricAtomicUsize {
pub(crate) fn load(&self, ordering: Ordering) -> usize {
self.value.load(ordering)
}

pub(crate) fn store(&self, val: usize, ordering: Ordering) {
self.value.store(val, ordering)
}
pub(crate) fn store(&self, val: usize, ordering: Ordering) {
self.value.store(val, ordering)
}

pub(crate) fn increment(&self) -> usize {
self.value.fetch_add(1, Ordering::Relaxed)
}
pub(crate) fn increment(&self) -> usize {
self.value.fetch_add(1, Ordering::Relaxed)
}

pub(crate) fn decrement(&self) -> usize {
self.value.fetch_sub(1, Ordering::Relaxed)
}
pub(crate) fn decrement(&self) -> usize {
self.value.fetch_sub(1, Ordering::Relaxed)
}
}

0 comments on commit 0b5a1cf

Please sign in to comment.