6#ifndef BITCOIN_SEMAPHORE_GRANT_H
7#define BITCOIN_SEMAPHORE_GRANT_H
16 std::counting_semaphore<LeastMaxValue>*
sem;
40 if (!fHaveGrant && sem->try_acquire()) {
54 fHaveGrant = other.fHaveGrant;
55 other.fHaveGrant =
false;
63 fHaveGrant = other.fHaveGrant;
64 other.fHaveGrant =
false;
85 explicit operator bool() const noexcept
RAII-style semaphore lock.
CountingSemaphoreGrant() noexcept
CountingSemaphoreGrant(CountingSemaphoreGrant &&other) noexcept
CountingSemaphoreGrant & operator=(CountingSemaphoreGrant &&other) noexcept
std::counting_semaphore< LeastMaxValue > * sem
bool TryAcquire() noexcept
~CountingSemaphoreGrant()
CountingSemaphoreGrant(std::counting_semaphore< LeastMaxValue > &sema, bool fTry=false) noexcept
CountingSemaphoreGrant(const CountingSemaphoreGrant &)=delete
CountingSemaphoreGrant & operator=(const CountingSemaphoreGrant &)=delete
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.