9 #ifndef CPPCOMMON_THREADS_FILE_LOCK_H
10 #define CPPCOMMON_THREADS_FILE_LOCK_H
133 Impl& impl() noexcept {
return reinterpret_cast<Impl&
>(_storage); }
134 const Impl& impl() const noexcept {
return reinterpret_cast<Impl const&
>(_storage); }
136 static const size_t StorageSize = 48;
137 static const size_t StorageAlign = 8;
138 alignas(StorageAlign) std::byte _storage[StorageSize];
File-lock synchronization primitive.
FileLock(const FileLock &)=delete
void UnlockRead()
Release read lock.
FileLock & operator=(const Path &path)
FileLock & operator=(FileLock &&lock)=delete
bool TryLockWrite()
Try to acquire write lock without block.
void LockRead()
Acquire read lock with block.
bool TryLockReadFor(const Timespan ×pan)
Try to acquire read lock for the given timespan.
const Path & path() const noexcept
Get the file-lock path.
FileLock & operator=(const FileLock &)=delete
void UnlockWrite()
Release write lock.
bool TryLockWriteUntil(const UtcTimestamp ×tamp)
Try to acquire write lock until the given timestamp.
bool TryLockReadUntil(const UtcTimestamp ×tamp)
Try to acquire read lock until the given timestamp.
bool TryLockRead()
Try to acquire read lock without block.
void Reset()
Reset file-lock.
bool TryLockWriteFor(const Timespan ×pan)
Try to acquire write lock for the given timespan.
void Assign(const Path &path)
Assign a new file-lock path.
void LockWrite()
Acquire write lock with block.
FileLock(FileLock &&lock)=delete
Filesystem file definition.
Locker synchronization primitive definition.
C++ Common project definitions.