9 #ifndef CPPCOMMON_THREADS_NAMED_CRITICAL_SECTION_H
10 #define CPPCOMMON_THREADS_NAMED_CRITICAL_SECTION_H
45 const std::string&
name()
const;
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 = 256;
92 static const size_t StorageAlign = 8;
93 alignas(StorageAlign) std::byte _storage[StorageSize];
Named critical section synchronization primitive.
NamedCriticalSection(const NamedCriticalSection &)=delete
bool TryLock()
Try to acquire critical section without block.
NamedCriticalSection & operator=(const NamedCriticalSection &)=delete
NamedCriticalSection & operator=(NamedCriticalSection &&cs)=delete
void Lock()
Acquire critical section with block.
NamedCriticalSection(NamedCriticalSection &&cs)=delete
bool TryLockUntil(const UtcTimestamp ×tamp)
Try to acquire critical section until the given timestamp.
void Unlock()
Release critical section.
const std::string & name() const
Get the critical section name.
NamedCriticalSection(const std::string &name)
Default class constructor.
bool TryLockFor(const Timespan ×pan)
Try to acquire critical section for the given timespan.
Locker synchronization primitive definition.
C++ Common project definitions.