34#include <NDEVR/BaseValues.h>
35#include <NDEVR/Dictionary.h>
36#include <NDEVR/Buffer.h>
132 bool _TryWriteLock();
135 std::mutex m_critical_section;
136 volatile uint04 m_write_owner;
137 volatile uint04 m_readers;
138 volatile uint04 m_writers;
139 volatile uint04 m_write_waiters;
185 RLock(
const void* lock,
bool& didAquire);
213 void operator=(
const RLock&) =
delete;
261 void sortAndAcquire();
295 void operator=(
const WLock&) =
delete;
376 void sortAndAcquire();
The equivelent of std::vector but with a bit more control.
bool isLocked() const
Returns whether all locks in this MultiRLock are currently held.
MultiRLock(std::initializer_list< const void * > l, uint08 timeout)
Constructs read locks on multiple entries with a timeout.
MultiRLock(MultiRLock &&lock) noexcept
Move constructor.
MultiRLock(std::initializer_list< RWLock * > l)
Constructs read locks on multiple RWLocks directly.
MultiRLock(std::initializer_list< const void * > l)
Constructs read locks on multiple entries identified by pointers.
MultiWLock(std::initializer_list< const void * > l, uint08 timeout)
Constructs write locks on multiple entries with a timeout.
MultiWLock(std::initializer_list< RWLock * > l)
Constructs write locks on multiple RWLocks directly.
bool isLocked() const
Returns whether all locks in this MultiWLock are currently held.
MultiWLock(std::initializer_list< const void * > l)
Constructs write locks on multiple entries identified by pointers.
MultiWLock(MultiWLock &&lock) noexcept
Move constructor.
RLock(RLock &&lock) noexcept
Move constructor.
RLock(const void *lock, uint08 timeout)
Constructs a read lock with a timeout, looking up the RWLock by pointer.
bool isLocked() const
Returns whether this RLock currently holds a read lock.
RLock(const void *lock)
Constructs a read lock by looking up the RWLock associated with the given pointer.
RLock(const void *lock, bool &didAquire)
Attempts to construct a read lock, reporting whether acquisition succeeded.
RLock(const UUID &lock)
Constructs a read lock by looking up the RWLock associated with the given UUID.
static bool HasLock(const void *lock)
Checks whether a read lock is currently held for the given pointer.
static bool HasLock(const RWLock &lock)
Checks whether a read lock is currently held on the given RWLock.
RLock(RWLock &lock)
Constructs a read lock on the given RWLock.
A readers-writer lock allowing concurrent reads or exclusive writes.
void readLock()
Acquires a read lock.
~RWLock()
Destroys the RWLock.
bool tryReadLock(uint08 time)
Attempts to acquire a read lock, waiting up to the specified time.
bool tryReadLock()
Attempts to acquire a read lock without blocking.
uint04 numOfWriteLocks() const
Returns the total number of write locks currently held.
bool tryWriteLock(uint08 time)
Attempts to acquire a write lock, waiting up to the specified time.
bool tryWriteLock()
Attempts to acquire a write lock without blocking.
void readUnlock()
Releases a previously acquired read lock.
uint04 numOfReadLocksHeld() const
Returns the number of read locks held by the calling thread.
RWLock()
Constructs a new RWLock with no locks held.
static RWLock * getEntry(const void *entry)
Retrieves the RWLock associated with the given pointer.
void writeUnlock()
Releases a previously acquired write lock.
uint04 numOfWriteLocksHeld() const
Returns the number of write locks held by the calling thread.
void writeLock()
Acquires a write lock.
uint04 numOfReadLocks() const
Returns the total number of read locks currently held.
Stores a time span, or difference between two times, with an optional start time.
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
WLock(const UUID &lock)
Constructs a write lock by looking up the RWLock associated with the given UUID.
WLock(const void *lock, uint08 timeout)
Constructs a write lock with a timeout, looking up the RWLock by pointer.
static bool HasLock(const RWLock &lock)
Checks whether a write lock is currently held on the given RWLock.
static bool HasLock(const void *lock)
Checks whether a write lock is currently held for the given pointer.
WLock(WLock &&lock) noexcept
Move constructor.
WLock(const void *lock)
Constructs a write lock by looking up the RWLock associated with the given pointer.
WLock(const void *lock, const TimeSpan &timeout)
Constructs a write lock with a TimeSpan timeout, looking up the RWLock by pointer.
bool isLocked() const
Returns whether this WLock currently holds a write lock.
WLock(RWLock &lock)
Constructs a write lock on the given RWLock.
The primary namespace for the NDEVR SDK.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...