MySQL 9.1.0
Source Code Documentation
|
This has the functionality of mysql_rwlock_t, with two differences: More...
#include <rpl_gtid.h>
Classes | |
class | Guard |
RAII class to acquire a lock for the duration of a block. More... | |
Public Types | |
enum | enum_lock_type { NO_LOCK , READ_LOCK , WRITE_LOCK , TRY_READ_LOCK , TRY_WRITE_LOCK } |
Public Member Functions | |
Checkable_rwlock (PSI_rwlock_key psi_key=0) | |
Initialize this Checkable_rwlock. More... | |
~Checkable_rwlock () | |
Destroy this Checkable_lock. More... | |
void | rdlock () |
Acquire the read lock. More... | |
void | wrlock () |
Acquire the write lock. More... | |
void | unlock () |
Release the lock (whether it is a write or read lock). More... | |
bool | is_wrlock () |
Return true if the write lock is held. More... | |
int | trywrlock () |
Return 0 if the write lock is held, otherwise an error will be returned. More... | |
int | tryrdlock () |
Return 0 if the read lock is held, otherwise an error will be returned. More... | |
void | assert_some_lock () const |
Assert that some thread holds either the read or the write lock. More... | |
void | assert_some_rdlock () const |
Assert that some thread holds the read lock. More... | |
void | assert_some_wrlock () const |
Assert that some thread holds the write lock. More... | |
void | assert_no_wrlock () const |
Assert that no thread holds the write lock. More... | |
void | assert_no_rdlock () const |
Assert that no thread holds the read lock. More... | |
void | assert_no_lock () const |
Assert that no thread holds read or write lock. More... | |
Public Attributes | |
bool | m_dbug_trace |
If enabled, print any lock/unlock operations to the DBUG trace. More... | |
Private Member Functions | |
int32 | get_state () const |
Read lock_state atomically and return the value. More... | |
Private Attributes | |
std::atomic< int32 > | m_lock_state |
The state of the lock: 0 - not locked -1 - write locked >0 - read locked by that many threads. More... | |
mysql_rwlock_t | m_rwlock {} |
The rwlock. More... | |
This has the functionality of mysql_rwlock_t, with two differences:
Note that the assertions do not check whether this thread has taken the lock (that would be more complicated as it would require a dynamic data structure). Luckily, it is still likely that the assertions find bugs where a thread forgot to take a lock, because most of the time most locks are only used by one thread at a time.
The assertions are no-ops when DBUG is off.
|
inline |
Initialize this Checkable_rwlock.
|
inline |
Destroy this Checkable_lock.
|
inline |
Assert that no thread holds read or write lock.
|
inline |
Assert that no thread holds the read lock.
|
inline |
Assert that no thread holds the write lock.
|
inline |
Assert that some thread holds either the read or the write lock.
|
inline |
Assert that some thread holds the read lock.
|
inline |
Assert that some thread holds the write lock.
|
inlineprivate |
Read lock_state atomically and return the value.
|
inline |
Return true if the write lock is held.
Must only be called by threads that hold a lock.
|
inline |
Acquire the read lock.
|
inline |
Return 0 if the read lock is held, otherwise an error will be returned.
|
inline |
Return 0 if the write lock is held, otherwise an error will be returned.
|
inline |
Release the lock (whether it is a write or read lock).
|
inline |
Acquire the write lock.
bool Checkable_rwlock::m_dbug_trace |
If enabled, print any lock/unlock operations to the DBUG trace.
|
private |
The state of the lock: 0 - not locked -1 - write locked >0 - read locked by that many threads.
|
private |
The rwlock.