Skip to content

Commit e6ce5f9

Browse files
committed
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-
1 parent 793166d commit e6ce5f9

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/sync.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -304,22 +304,22 @@ inline MutexType* MaybeCheckNotHeld(MutexType* m) LOCKS_EXCLUDED(m) LOCK_RETURNE
304304
*
305305
* See https://en.wikipedia.org/wiki/Semaphore_(programming)
306306
*/
307-
class CSemaphore
307+
class CountingSemaphore
308308
{
309309
private:
310310
std::condition_variable condition;
311311
std::mutex mutex;
312312
int value;
313313

314314
public:
315-
explicit CSemaphore(int init) noexcept : value(init) {}
315+
explicit CountingSemaphore(int init) noexcept : value(init) {}
316316

317317
// Disallow default construct, copy, move.
318-
CSemaphore() = delete;
319-
CSemaphore(const CSemaphore&) = delete;
320-
CSemaphore(CSemaphore&&) = delete;
321-
CSemaphore& operator=(const CSemaphore&) = delete;
322-
CSemaphore& operator=(CSemaphore&&) = delete;
318+
CountingSemaphore() = delete;
319+
CountingSemaphore(const CountingSemaphore&) = delete;
320+
CountingSemaphore(CountingSemaphore&&) = delete;
321+
CountingSemaphore& operator=(const CountingSemaphore&) = delete;
322+
CountingSemaphore& operator=(CountingSemaphore&&) = delete;
323323

324324
void acquire() noexcept
325325
{
@@ -348,14 +348,14 @@ class CSemaphore
348348
}
349349
};
350350

351-
using BinarySemaphore = CSemaphore;
352-
using Semaphore = CSemaphore;
351+
using BinarySemaphore = CountingSemaphore;
352+
using Semaphore = CountingSemaphore;
353353

354354
/** RAII-style semaphore lock */
355-
class CSemaphoreGrant
355+
class CountingSemaphoreGrant
356356
{
357357
private:
358-
CSemaphore* sem;
358+
CountingSemaphore* sem;
359359
bool fHaveGrant;
360360

361361
public:
@@ -386,19 +386,19 @@ class CSemaphoreGrant
386386
}
387387

388388
// Disallow copy.
389-
CSemaphoreGrant(const CSemaphoreGrant&) = delete;
390-
CSemaphoreGrant& operator=(const CSemaphoreGrant&) = delete;
389+
CountingSemaphoreGrant(const CountingSemaphoreGrant&) = delete;
390+
CountingSemaphoreGrant& operator=(const CountingSemaphoreGrant&) = delete;
391391

392392
// Allow move.
393-
CSemaphoreGrant(CSemaphoreGrant&& other) noexcept
393+
CountingSemaphoreGrant(CountingSemaphoreGrant&& other) noexcept
394394
{
395395
sem = other.sem;
396396
fHaveGrant = other.fHaveGrant;
397397
other.fHaveGrant = false;
398398
other.sem = nullptr;
399399
}
400400

401-
CSemaphoreGrant& operator=(CSemaphoreGrant&& other) noexcept
401+
CountingSemaphoreGrant& operator=(CountingSemaphoreGrant&& other) noexcept
402402
{
403403
Release();
404404
sem = other.sem;
@@ -408,9 +408,9 @@ class CSemaphoreGrant
408408
return *this;
409409
}
410410

411-
CSemaphoreGrant() noexcept : sem(nullptr), fHaveGrant(false) {}
411+
CountingSemaphoreGrant() noexcept : sem(nullptr), fHaveGrant(false) {}
412412

413-
explicit CSemaphoreGrant(CSemaphore& sema, bool fTry = false) noexcept : sem(&sema), fHaveGrant(false)
413+
explicit CountingSemaphoreGrant(CountingSemaphore& sema, bool fTry = false) noexcept : sem(&sema), fHaveGrant(false)
414414
{
415415
if (fTry) {
416416
TryAcquire();
@@ -419,7 +419,7 @@ class CSemaphoreGrant
419419
}
420420
}
421421

422-
~CSemaphoreGrant()
422+
~CountingSemaphoreGrant()
423423
{
424424
Release();
425425
}
@@ -430,7 +430,7 @@ class CSemaphoreGrant
430430
}
431431
};
432432

433-
using BinarySemaphoreGrant = CSemaphoreGrant;
434-
using SemaphoreGrant = CSemaphoreGrant;
433+
using BinarySemaphoreGrant = CountingSemaphoreGrant;
434+
using SemaphoreGrant = CountingSemaphoreGrant;
435435

436436
#endif // BITCOIN_SYNC_H

0 commit comments

Comments
 (0)