NDEVR
API Documentation

Used to lock a particular variable for writing. More...

Public Member Functions

 WLock (const UUID &lock)
 Constructs a write lock by looking up the RWLock associated with the given UUID.
 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.
 WLock (const void *lock, uint08 timeout)
 Constructs a write lock with a timeout, looking up the RWLock by pointer.
 WLock (RWLock &lock)
 Constructs a write lock on the given RWLock.
 WLock (WLock &&lock) noexcept
 Move constructor.
 ~WLock ()
 Destructor.
bool isLocked () const
 Returns whether this WLock currently holds a write lock.

Static Public Member Functions

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.

Detailed Description

Used to lock a particular variable for writing.


Only one write lock can be created when no read locks are on a variable, otherwise will wait. Note: Automatically unlocks on destruction.

See also
RWLock, RLock, MultiWLock

Definition at line 271 of file RWLock.h.

Constructor & Destructor Documentation

◆ WLock() [1/6]

WLock::WLock ( const void * lock)
explicit

Constructs a write lock by looking up the RWLock associated with the given pointer.

Parameters
[in]lockThe pointer key used to look up the RWLock.

Referenced by WLock().

◆ WLock() [2/6]

WLock::WLock ( const UUID & lock)
explicit

Constructs a write lock by looking up the RWLock associated with the given UUID.

Parameters
[in]lockThe UUID key used to look up the RWLock.

◆ WLock() [3/6]

WLock::WLock ( RWLock & lock)
explicit

Constructs a write lock on the given RWLock.

Parameters
[in]lockThe RWLock to acquire a write lock on.

◆ WLock() [4/6]

WLock::WLock ( WLock && lock)
noexcept

Move constructor.

Transfers lock ownership from another WLock.

Parameters
[in]lockThe WLock to move from.

References WLock().

◆ WLock() [5/6]

WLock::WLock ( const void * lock,
uint08 timeout )

Constructs a write lock with a timeout, looking up the RWLock by pointer.

Parameters
[in]lockThe pointer key used to look up the RWLock.
[in]timeoutThe maximum time in nanoseconds to wait for the lock.

◆ WLock() [6/6]

WLock::WLock ( const void * lock,
const TimeSpan & timeout )

Constructs a write lock with a TimeSpan timeout, looking up the RWLock by pointer.

Parameters
[in]lockThe pointer key used to look up the RWLock.
[in]timeoutThe maximum duration to wait for the lock.

◆ ~WLock()

WLock::~WLock ( )

Destructor.

Releases the write lock if held.

Member Function Documentation

◆ HasLock() [1/2]

bool WLock::HasLock ( const RWLock & lock)
static

Checks whether a write lock is currently held on the given RWLock.

Parameters
[in]lockThe RWLock to check.
Returns
True if a write lock is held.

◆ HasLock() [2/2]

bool WLock::HasLock ( const void * lock)
static

Checks whether a write lock is currently held for the given pointer.

Parameters
[in]lockThe pointer key to check.
Returns
True if a write lock is held for the entry.

◆ isLocked()

bool WLock::isLocked ( ) const

Returns whether this WLock currently holds a write lock.

Returns
True if the lock is held.

The documentation for this class was generated from the following file: