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