From: Elias Rohrer Date: Wed, 18 Sep 2024 07:39:18 +0000 (+0200) Subject: `rustfmt`: Run on `util/atomic_counter.rs` X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=95fd1f7bc7857f7d25888537673632ad48b6e5d9;p=rust-lightning `rustfmt`: Run on `util/atomic_counter.rs` --- diff --git a/lightning/src/util/atomic_counter.rs b/lightning/src/util/atomic_counter.rs index 050bcadf8..38a33aa82 100644 --- a/lightning/src/util/atomic_counter.rs +++ b/lightning/src/util/atomic_counter.rs @@ -1,9 +1,9 @@ //! A simple atomic counter that uses mutexes if the platform doesn't support atomic u64s. -#[cfg(target_has_atomic = "64")] -use core::sync::atomic::{AtomicU64, Ordering}; #[cfg(not(target_has_atomic = "64"))] use crate::sync::Mutex; +#[cfg(target_has_atomic = "64")] +use core::sync::atomic::{AtomicU64, Ordering}; pub(crate) struct AtomicCounter { #[cfg(target_has_atomic = "64")] @@ -22,10 +22,12 @@ impl AtomicCounter { } } pub(crate) fn next(&self) -> u64 { - #[cfg(target_has_atomic = "64")] { + #[cfg(target_has_atomic = "64")] + { self.counter.fetch_add(1, Ordering::AcqRel) } - #[cfg(not(target_has_atomic = "64"))] { + #[cfg(not(target_has_atomic = "64"))] + { let mut mtx = self.counter.lock().unwrap(); *mtx += 1; *mtx - 1 @@ -33,12 +35,14 @@ impl AtomicCounter { } #[cfg(test)] pub(crate) fn set_counter(&self, count: u64) { - #[cfg(target_has_atomic = "64")] { + #[cfg(target_has_atomic = "64")] + { self.counter.store(count, Ordering::Release); } - #[cfg(not(target_has_atomic = "64"))] { + #[cfg(not(target_has_atomic = "64"))] + { let mut mtx = self.counter.lock().unwrap(); - *mtx = count; + *mtx = count; } } }