9 #ifndef CPPCOMMON_THREADS_SEMAPHORE_H
10 #define CPPCOMMON_THREADS_SEMAPHORE_H
88 Impl& impl() noexcept {
return reinterpret_cast<Impl&
>(_storage); }
89 const Impl& impl() const noexcept {
return reinterpret_cast<Impl const&
>(_storage); }
91 static const size_t StorageSize = 40;
92 static const size_t StorageAlign = 8;
93 alignas(StorageAlign) std::byte _storage[StorageSize];
Semaphore synchronization primitive.
Semaphore(int resources)
Default class constructor.
bool TryLock()
Try to acquire semaphore without block.
Semaphore(const Semaphore &)=delete
Semaphore & operator=(const Semaphore &)=delete
bool TryLockFor(const Timespan ×pan)
Try to acquire semaphore for the given timespan.
int resources() const noexcept
Get the semaphore resources counter.
Semaphore & operator=(Semaphore &&semaphore)=delete
Semaphore(Semaphore &&semaphore)=delete
bool TryLockUntil(const UtcTimestamp ×tamp)
Try to acquire semaphore until the given timestamp.
void Unlock()
Release semaphore.
void Lock()
Acquire semaphore with block.
Locker synchronization primitive definition.
C++ Common project definitions.