From 95fd1f7bc7857f7d25888537673632ad48b6e5d9 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Wed, 18 Sep 2024 09:39:18 +0200 Subject: [PATCH] `rustfmt`: Run on `util/atomic_counter.rs` --- lightning/src/util/atomic_counter.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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; } } } -- 2.39.5