From e6ce5f9e78741ef7f88a8ad237f4b772da921dc3 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Thu, 8 May 2025 18:39:23 +0000 Subject: [PATCH] scripted-diff: rename CSemaphore and CSemaphoreGrant CountingSemaphore and CountingSemaphoreGrant model std::counting_semaphore. -BEGIN VERIFY SCRIPT- sed -i -e 's|CSemaphoreGrant|CountingSemaphoreGrant|g' -e 's|CSemaphore|CountingSemaphore|g' src/sync.h -END VERIFY SCRIPT- --- src/sync.h | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/sync.h b/src/sync.h index 8c1d26c134..45298a0ee8 100644 --- a/src/sync.h +++ b/src/sync.h @@ -304,7 +304,7 @@ inline MutexType* MaybeCheckNotHeld(MutexType* m) LOCKS_EXCLUDED(m) LOCK_RETURNE * * See https://en.wikipedia.org/wiki/Semaphore_(programming) */ -class CSemaphore +class CountingSemaphore { private: std::condition_variable condition; @@ -312,14 +312,14 @@ private: int value; public: - explicit CSemaphore(int init) noexcept : value(init) {} + explicit CountingSemaphore(int init) noexcept : value(init) {} // Disallow default construct, copy, move. - CSemaphore() = delete; - CSemaphore(const CSemaphore&) = delete; - CSemaphore(CSemaphore&&) = delete; - CSemaphore& operator=(const CSemaphore&) = delete; - CSemaphore& operator=(CSemaphore&&) = delete; + CountingSemaphore() = delete; + CountingSemaphore(const CountingSemaphore&) = delete; + CountingSemaphore(CountingSemaphore&&) = delete; + CountingSemaphore& operator=(const CountingSemaphore&) = delete; + CountingSemaphore& operator=(CountingSemaphore&&) = delete; void acquire() noexcept { @@ -348,14 +348,14 @@ public: } }; -using BinarySemaphore = CSemaphore; -using Semaphore = CSemaphore; +using BinarySemaphore = CountingSemaphore; +using Semaphore = CountingSemaphore; /** RAII-style semaphore lock */ -class CSemaphoreGrant +class CountingSemaphoreGrant { private: - CSemaphore* sem; + CountingSemaphore* sem; bool fHaveGrant; public: @@ -386,11 +386,11 @@ public: } // Disallow copy. - CSemaphoreGrant(const CSemaphoreGrant&) = delete; - CSemaphoreGrant& operator=(const CSemaphoreGrant&) = delete; + CountingSemaphoreGrant(const CountingSemaphoreGrant&) = delete; + CountingSemaphoreGrant& operator=(const CountingSemaphoreGrant&) = delete; // Allow move. - CSemaphoreGrant(CSemaphoreGrant&& other) noexcept + CountingSemaphoreGrant(CountingSemaphoreGrant&& other) noexcept { sem = other.sem; fHaveGrant = other.fHaveGrant; @@ -398,7 +398,7 @@ public: other.sem = nullptr; } - CSemaphoreGrant& operator=(CSemaphoreGrant&& other) noexcept + CountingSemaphoreGrant& operator=(CountingSemaphoreGrant&& other) noexcept { Release(); sem = other.sem; @@ -408,9 +408,9 @@ public: return *this; } - CSemaphoreGrant() noexcept : sem(nullptr), fHaveGrant(false) {} + CountingSemaphoreGrant() noexcept : sem(nullptr), fHaveGrant(false) {} - explicit CSemaphoreGrant(CSemaphore& sema, bool fTry = false) noexcept : sem(&sema), fHaveGrant(false) + explicit CountingSemaphoreGrant(CountingSemaphore& sema, bool fTry = false) noexcept : sem(&sema), fHaveGrant(false) { if (fTry) { TryAcquire(); @@ -419,7 +419,7 @@ public: } } - ~CSemaphoreGrant() + ~CountingSemaphoreGrant() { Release(); } @@ -430,7 +430,7 @@ public: } }; -using BinarySemaphoreGrant = CSemaphoreGrant; -using SemaphoreGrant = CSemaphoreGrant; +using BinarySemaphoreGrant = CountingSemaphoreGrant; +using SemaphoreGrant = CountingSemaphoreGrant; #endif // BITCOIN_SYNC_H