|
pstore2
|
A synchronization object that can be used to protect data in a file from being simultaneously accessed by multiple processes. More...
#include <file.hpp>
Public Member Functions | |
| range_lock () noexcept=default | |
| Default constructs an instance of range_lock. More... | |
| range_lock (file_base *const file, std::uint64_t offset, std::size_t size, file_base::lock_kind kind) noexcept | |
| range_lock (range_lock const &other)=delete | |
| range_lock (range_lock &&other) noexcept | |
| ~range_lock () noexcept | |
| Destroys the range lock. More... | |
| range_lock & | operator= (range_lock &&other) noexcept |
| Move assignment operator. More... | |
| range_lock & | operator= (range_lock const &)=delete |
| bool | lock () |
| Blocks until a lock can be obtained for the current thread. More... | |
| bool | try_lock () |
| Attempts to acquire the lock for the current thread without blocking. More... | |
| void | unlock () |
| Releases the file range lock which should be previously be locked by a call to lock() or try_lock(). More... | |
Observers | |
| file_base * | file () noexcept |
| file_base const * | file () const noexcept |
| std::uint64_t | offset () const noexcept |
| std::size_t | size () const noexcept |
| file_base::lock_kind | kind () const noexcept |
| bool | is_locked () const noexcept |
A synchronization object that can be used to protect data in a file from being simultaneously accessed by multiple processes.
It supports a non-recursive multiple-reader/single writer access model:
The behavior of the program is undefined if a range lock is destroyed while still owned. The range_lock class satisfies all requirements of Lockable and StandardLayoutType; it is not copyable.
|
defaultnoexcept |
Default constructs an instance of range_lock.
The following values are set:
|
noexcept |
| file | The file whose contents are to be range-locked. |
| offset | The offset of the first byte of the file to be locked. |
| size | The number of bytes to be locked. |
| kind | Specifies the type of lock to be obtained |
|
noexcept |
Destroys the range lock.
If the lock is owned, it will be unlocked but an error will be lost.
|
inlinenoexcept |
| bool pstore::file::range_lock::lock | ( | ) |
Blocks until a lock can be obtained for the current thread.
If an exception is thrown, no lock is obtained.
|
inlinenoexcept |
|
noexcept |
Move assignment operator.
Replaces the contents with those of "other" using move semantics. If prior to the call *this has an associated mutex and has acquired ownership of it, the mutex is unlocked. If this operation fails, the resulting exception is dropped.
|
inlinenoexcept |
| bool pstore::file::range_lock::try_lock | ( | ) |
Attempts to acquire the lock for the current thread without blocking.
If an exception is thrown, no lock is obtained.
| void pstore::file::range_lock::unlock | ( | ) |
Releases the file range lock which should be previously be locked by a call to lock() or try_lock().
1.8.13