libUTL++
utl::RWlockGuard Class Reference

Acquire/release a RWlock RAII-style. More...

#include <RWlock.h>

Public Member Functions

 RWlockGuard ()
 Default constructor. More...
 
 RWlockGuard (RWlock *rwlock, uint_t mode)
 Constructor. More...
 
 ~RWlockGuard ()
 Destructor. More...
 
void lock (RWlock *rwlock, uint_t mode)
 Acquire read- or write-lock. More...
 
void lock (uint_t mode)
 Acquire read- or write-lock. More...
 
void rdlock (RWlock *rwlock)
 Acquire read-lock. More...
 
void wrlock (RWlock *rwlock)
 Acquire write-lock. More...
 
void rdlock ()
 Acquire read-lock. More...
 
void wrlock ()
 Acquire write-lock. More...
 
bool trylock (RWlock *rwlock, uint_t mode)
 Try to acquire read- or write-lock (without blocking). More...
 
bool trylock (uint_t mode)
 Try to acquire read- or write-lock (without blocking). More...
 
bool tryrdlock (RWlock *rwlock)
 Try to acquire read-lock (without blocking). More...
 
bool trywrlock (RWlock *rwlock)
 Try to acquire write-lock (without blocking). More...
 
bool tryrdlock ()
 Try to acquire read-lock (without blocking). More...
 
bool trywrlock ()
 Try to acquire write-lock (without blocking). More...
 
void unlock ()
 Release the lock. More...
 

Detailed Description

Acquire/release a RWlock RAII-style.

Author
Adam McKee

Definition at line 116 of file RWlock.h.

Constructor & Destructor Documentation

◆ RWlockGuard() [1/2]

utl::RWlockGuard::RWlockGuard ( )
inline

Default constructor.

Definition at line 120 of file RWlock.h.

◆ RWlockGuard() [2/2]

utl::RWlockGuard::RWlockGuard ( RWlock rwlock,
uint_t  mode 
)
inline

Constructor.

Parameters
rwlockRWlock to lock
mode(io_rd : read-lock, io_wr : write-lock)

Definition at line 131 of file RWlock.h.

◆ ~RWlockGuard()

utl::RWlockGuard::~RWlockGuard ( )
inline

Destructor.

Definition at line 139 of file RWlock.h.

Member Function Documentation

◆ lock() [1/2]

void utl::RWlockGuard::lock ( RWlock rwlock,
uint_t  mode 
)
inline

Acquire read- or write-lock.

Parameters
rwlockRWlock to lock
mode(io_rd : read-lock, io_wr : write-lock)

Definition at line 150 of file RWlock.h.

◆ lock() [2/2]

void utl::RWlockGuard::lock ( uint_t  mode)
inline

Acquire read- or write-lock.

Parameters
mode(io_rd : read-lock, io_wr : write-lock)

Definition at line 162 of file RWlock.h.

References utl::io_rd.

◆ rdlock() [1/2]

void utl::RWlockGuard::rdlock ( RWlock rwlock)
inline

Acquire read-lock.

Parameters
rwlockRWlock to lock

Definition at line 172 of file RWlock.h.

◆ wrlock() [1/2]

void utl::RWlockGuard::wrlock ( RWlock rwlock)
inline

Acquire write-lock.

Parameters
rwlockRWlock to lock

Definition at line 184 of file RWlock.h.

◆ rdlock() [2/2]

void utl::RWlockGuard::rdlock ( )
inline

Acquire read-lock.

Definition at line 193 of file RWlock.h.

◆ wrlock() [2/2]

void utl::RWlockGuard::wrlock ( )
inline

Acquire write-lock.

Definition at line 201 of file RWlock.h.

◆ trylock() [1/2]

bool utl::RWlockGuard::trylock ( RWlock rwlock,
uint_t  mode 
)
inline

Try to acquire read- or write-lock (without blocking).

Parameters
rwlockRWlock to lock
mode(io_rd : read-lock, io_wr : write-lock)
Returns
true if lock acquired, false otherwise

Definition at line 214 of file RWlock.h.

◆ trylock() [2/2]

bool utl::RWlockGuard::trylock ( uint_t  mode)
inline

Try to acquire read- or write-lock (without blocking).

Parameters
mode(io_rd : read-lock, io_wr : write-lock)
Returns
true if lock acquired, false otherwise

Definition at line 227 of file RWlock.h.

References utl::io_rd.

◆ tryrdlock() [1/2]

bool utl::RWlockGuard::tryrdlock ( RWlock rwlock)
inline

Try to acquire read-lock (without blocking).

Parameters
rwlockRWlock to lock
Returns
true if read-lock acquired, false otherwise

Definition at line 238 of file RWlock.h.

◆ trywrlock() [1/2]

bool utl::RWlockGuard::trywrlock ( RWlock rwlock)
inline

Try to acquire write-lock (without blocking).

Parameters
rwlockRWlock to lock
Returns
true if write-lock acquired, false otherwise

Definition at line 251 of file RWlock.h.

◆ tryrdlock() [2/2]

bool utl::RWlockGuard::tryrdlock ( )
inline

Try to acquire read-lock (without blocking).

Returns
true if read-lock acquired, false otherwise

Definition at line 263 of file RWlock.h.

◆ trywrlock() [2/2]

bool utl::RWlockGuard::trywrlock ( )
inline

Try to acquire write-lock (without blocking).

Returns
true if write-lock acquired, false otherwise

Definition at line 274 of file RWlock.h.

◆ unlock()

void utl::RWlockGuard::unlock ( )
inline

Release the lock.

Definition at line 282 of file RWlock.h.

References ASSERTD, and utl::io_rd.


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