MySQL 8.4.2
Source Code Documentation
Checkable_rwlock::Guard Class Reference

RAII class to acquire a lock for the duration of a block. More...

#include <rpl_gtid.h>

Public Member Functions

 Guard (Checkable_rwlock &lock, enum_lock_type lock_type)
 Create a guard, and optionally acquire a lock on it. More...
 
 Guard (Checkable_rwlock &lock, enum_lock_type lock_type, std::adopt_lock_t t)
 Create a guard, assuming the caller already holds a lock on it. More...
 
 Guard (Guard const &copy)=delete
 Objects of this class should not be copied or moved. More...
 
 Guard (Guard const &&copy)=delete
 
 ~Guard ()
 Unlock on destruct. More...
 
void rdlock ()
 Acquire the read lock. More...
 
void wrlock ()
 Acquire the write lock. More...
 
int trywrlock ()
 Try to acquire the write lock, and fail if it cannot be immediately granted. More...
 
int tryrdlock ()
 Try to acquire a read lock, and fail if it cannot be immediately granted. More...
 
void unlock ()
 Unlock the lock. More...
 
void unlock_if_locked ()
 Unlock the lock, if it was acquired by this guard. More...
 
Checkable_rwlockget_lock () const
 Return the underlying Checkable_rwlock object. More...
 
bool is_rdlocked () const
 Return true if this object is read locked. More...
 
bool is_wrlocked () const
 Return true if this object is write locked. More...
 
bool is_locked () const
 Return true if this object is either read locked or write locked. More...
 

Private Attributes

Checkable_rwlockm_lock
 
enum_lock_type m_lock_type
 

Detailed Description

RAII class to acquire a lock for the duration of a block.

Constructor & Destructor Documentation

◆ Guard() [1/4]

Checkable_rwlock::Guard::Guard ( Checkable_rwlock lock,
enum_lock_type  lock_type 
)
inline

Create a guard, and optionally acquire a lock on it.

◆ Guard() [2/4]

Checkable_rwlock::Guard::Guard ( Checkable_rwlock lock,
enum_lock_type  lock_type,
std::adopt_lock_t  t 
)
inline

Create a guard, assuming the caller already holds a lock on it.

◆ Guard() [3/4]

Checkable_rwlock::Guard::Guard ( Guard const &  copy)
delete

Objects of this class should not be copied or moved.

◆ Guard() [4/4]

Checkable_rwlock::Guard::Guard ( Guard const &&  copy)
delete

◆ ~Guard()

Checkable_rwlock::Guard::~Guard ( )
inline

Unlock on destruct.

Member Function Documentation

◆ get_lock()

Checkable_rwlock & Checkable_rwlock::Guard::get_lock ( ) const
inline

Return the underlying Checkable_rwlock object.

◆ is_locked()

bool Checkable_rwlock::Guard::is_locked ( ) const
inline

Return true if this object is either read locked or write locked.

◆ is_rdlocked()

bool Checkable_rwlock::Guard::is_rdlocked ( ) const
inline

Return true if this object is read locked.

◆ is_wrlocked()

bool Checkable_rwlock::Guard::is_wrlocked ( ) const
inline

Return true if this object is write locked.

◆ rdlock()

void Checkable_rwlock::Guard::rdlock ( )
inline

Acquire the read lock.

◆ tryrdlock()

int Checkable_rwlock::Guard::tryrdlock ( )
inline

Try to acquire a read lock, and fail if it cannot be immediately granted.

◆ trywrlock()

int Checkable_rwlock::Guard::trywrlock ( )
inline

Try to acquire the write lock, and fail if it cannot be immediately granted.

◆ unlock()

void Checkable_rwlock::Guard::unlock ( )
inline

Unlock the lock.

◆ unlock_if_locked()

void Checkable_rwlock::Guard::unlock_if_locked ( )
inline

Unlock the lock, if it was acquired by this guard.

◆ wrlock()

void Checkable_rwlock::Guard::wrlock ( )
inline

Acquire the write lock.

Member Data Documentation

◆ m_lock

Checkable_rwlock& Checkable_rwlock::Guard::m_lock
private

◆ m_lock_type

enum_lock_type Checkable_rwlock::Guard::m_lock_type
private

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