9 #ifndef CPPCOMMON_THREADS_NAMED_RW_LOCK_H
10 #define CPPCOMMON_THREADS_NAMED_RW_LOCK_H
48 const std::string&
name()
const;
159 Impl& impl() noexcept {
return reinterpret_cast<Impl&
>(_storage); }
160 const Impl& impl() const noexcept {
return reinterpret_cast<Impl const&
>(_storage); }
162 static const size_t StorageSize = 184;
163 static const size_t StorageAlign = 8;
164 alignas(StorageAlign) std::byte _storage[StorageSize];
Named read/write lock synchronization primitive.
void UnlockRead()
Release read lock.
void UnlockWrite()
Release write lock.
bool TryConvertWriteToRead()
Try to convert write lock to read lock without block.
bool TryLockReadFor(const Timespan ×pan)
Try to acquire read lock for the given timespan.
void LockRead()
Acquire read lock with block.
NamedRWLock(NamedRWLock &&lock)=delete
bool TryLockWrite()
Try to acquire write lock without block.
bool TryConvertWriteToReadUntil(const UtcTimestamp ×tamp)
Try to convert write lock to read lock until the given timestamp.
void ConvertWriteToRead()
Convert write lock to read lock without block.
bool TryLockReadUntil(const UtcTimestamp ×tamp)
Try to acquire read lock until the given timestamp.
bool TryLockRead()
Try to acquire read lock without block.
NamedRWLock(const NamedRWLock &)=delete
bool TryLockWriteFor(const Timespan ×pan)
Try to acquire write lock for the given timespan.
bool TryLockWriteUntil(const UtcTimestamp ×tamp)
Try to acquire write lock until the given timestamp.
NamedRWLock & operator=(const NamedRWLock &)=delete
void LockWrite()
Acquire write lock with block.
NamedRWLock(const std::string &name)
Default class constructor.
NamedRWLock & operator=(NamedRWLock &&lock)=delete
const std::string & name() const
Get the read/write lock name.
bool TryConvertWriteToReadFor(const Timespan ×pan)
Try to convert write lock to read lock for the given timespan.
Locker synchronization primitive definition.
C++ Common project definitions.