@@ -304,22 +304,22 @@ inline MutexType* MaybeCheckNotHeld(MutexType* m) LOCKS_EXCLUDED(m) LOCK_RETURNE
304
304
*
305
305
* See https://en.wikipedia.org/wiki/Semaphore_(programming)
306
306
*/
307
- class CSemaphore
307
+ class CountingSemaphore
308
308
{
309
309
private:
310
310
std::condition_variable condition;
311
311
std::mutex mutex;
312
312
int value;
313
313
314
314
public:
315
- explicit CSemaphore (int init) noexcept : value(init) {}
315
+ explicit CountingSemaphore (int init) noexcept : value(init) {}
316
316
317
317
// 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 ;
323
323
324
324
void acquire () noexcept
325
325
{
@@ -348,14 +348,14 @@ class CSemaphore
348
348
}
349
349
};
350
350
351
- using BinarySemaphore = CSemaphore ;
352
- using Semaphore = CSemaphore ;
351
+ using BinarySemaphore = CountingSemaphore ;
352
+ using Semaphore = CountingSemaphore ;
353
353
354
354
/* * RAII-style semaphore lock */
355
- class CSemaphoreGrant
355
+ class CountingSemaphoreGrant
356
356
{
357
357
private:
358
- CSemaphore * sem;
358
+ CountingSemaphore * sem;
359
359
bool fHaveGrant ;
360
360
361
361
public:
@@ -386,19 +386,19 @@ class CSemaphoreGrant
386
386
}
387
387
388
388
// Disallow copy.
389
- CSemaphoreGrant (const CSemaphoreGrant &) = delete ;
390
- CSemaphoreGrant & operator =(const CSemaphoreGrant &) = delete ;
389
+ CountingSemaphoreGrant (const CountingSemaphoreGrant &) = delete ;
390
+ CountingSemaphoreGrant & operator =(const CountingSemaphoreGrant &) = delete ;
391
391
392
392
// Allow move.
393
- CSemaphoreGrant (CSemaphoreGrant && other) noexcept
393
+ CountingSemaphoreGrant (CountingSemaphoreGrant && other) noexcept
394
394
{
395
395
sem = other.sem ;
396
396
fHaveGrant = other.fHaveGrant ;
397
397
other.fHaveGrant = false ;
398
398
other.sem = nullptr ;
399
399
}
400
400
401
- CSemaphoreGrant & operator =(CSemaphoreGrant && other) noexcept
401
+ CountingSemaphoreGrant & operator =(CountingSemaphoreGrant && other) noexcept
402
402
{
403
403
Release ();
404
404
sem = other.sem ;
@@ -408,9 +408,9 @@ class CSemaphoreGrant
408
408
return *this ;
409
409
}
410
410
411
- CSemaphoreGrant () noexcept : sem(nullptr ), fHaveGrant (false ) {}
411
+ CountingSemaphoreGrant () noexcept : sem(nullptr ), fHaveGrant (false ) {}
412
412
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 )
414
414
{
415
415
if (fTry ) {
416
416
TryAcquire ();
@@ -419,7 +419,7 @@ class CSemaphoreGrant
419
419
}
420
420
}
421
421
422
- ~CSemaphoreGrant ()
422
+ ~CountingSemaphoreGrant ()
423
423
{
424
424
Release ();
425
425
}
@@ -430,7 +430,7 @@ class CSemaphoreGrant
430
430
}
431
431
};
432
432
433
- using BinarySemaphoreGrant = CSemaphoreGrant ;
434
- using SemaphoreGrant = CSemaphoreGrant ;
433
+ using BinarySemaphoreGrant = CountingSemaphoreGrant ;
434
+ using SemaphoreGrant = CountingSemaphoreGrant ;
435
435
436
436
#endif // BITCOIN_SYNC_H
0 commit comments