]> git.bitcoin.ninja Git - rust-lightning/commitdiff
`rustfmt`: Run on `util/atomic_counter.rs`
authorElias Rohrer <dev@tnull.de>
Wed, 18 Sep 2024 07:39:18 +0000 (09:39 +0200)
committerElias Rohrer <dev@tnull.de>
Thu, 19 Sep 2024 07:31:21 +0000 (09:31 +0200)
lightning/src/util/atomic_counter.rs

index 050bcadf807894334a315a3968fe0fa46d27b56a..38a33aa82686040b53f3a8a15b932cb3dbcc1341 100644 (file)
@@ -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;
                }
        }
 }