MySQL 8.0.39
Source Code Documentation
|
The structure used in the spin lock implementation of a read-write lock. More...
#include <sync0rw.h>
Public Member Functions | |
rw_lock_t ()=default | |
rw_lock_t (const rw_lock_t &)=delete | |
rw_lock_t is not a copyable object, the reasoning behind this is the same as the reasoning behind why std::mutex is not copyable. More... | |
rw_lock_t & | operator= (const rw_lock_t &)=delete |
UT_LIST_NODE_T (rw_lock_t) list | |
All allocated rw locks are put into a list. More... | |
~rw_lock_t () override | |
Destructor. More... | |
virtual std::string | to_string () const override |
Print the rw-lock information. More... | |
virtual std::string | locked_from () const override |
Print where it was locked from. More... | |
UT_LIST_BASE_NODE_T (rw_lock_debug_t, list) debug_list | |
In the debug version: pointer to the debug info list of the lock. More... | |
bool | is_x_blocked_by_s () |
Checks if there is a thread requesting an x-latch waiting for threads to release their s-latches. More... | |
Public Member Functions inherited from latch_t | |
latch_t (latch_id_t id=LATCH_ID_NONE) 1 | |
Constructor. More... | |
latch_t & | operator= (const latch_t &)=default |
virtual | ~latch_t () 1=default |
Destructor. More... | |
latch_id_t | get_id () const |
bool | is_rw_lock () const 1 |
latch_level_t | get_level () const 1 |
bool | is_temp_fsp () const 1 |
void | set_temp_fsp () 1 |
Set the temporary tablespace flag. More... | |
const char * | get_name () const 1 |
Public Attributes | |
std::atomic< int32_t > | lock_word |
Holds the state of the lock. More... | |
std::atomic< bool > | waiters |
1: there are waiters More... | |
std::atomic< bool > | recursive |
Default value false which means the lock is non-recursive. More... | |
volatile ulint | sx_recursive |
number of granted SX locks. More... | |
std::atomic< std::thread::id > | writer_thread |
Thread id of writer thread. More... | |
Atomic_xor_of_thread_id | reader_thread |
XOR of reader threads' IDs. More... | |
os_event_t | event |
Used by sync0arr.cc for thread queueing. More... | |
os_event_t | wait_ex_event |
Event for next-writer to wait on. More... | |
ut::Location | clocation |
Location where lock created. More... | |
const char * | last_s_file_name |
last s-lock file/line is not guaranteed to be correct More... | |
const char * | last_x_file_name |
File name where last x-locked. More... | |
bool | is_block_lock |
If 1 then the rw-lock is a block lock. More... | |
uint16_t | last_s_line |
Line number where last time s-locked. More... | |
uint16_t | last_x_line |
Line number where last time x-locked. More... | |
uint32_t | count_os_wait |
Count of os_waits. More... | |
struct PSI_rwlock * | pfs_psi |
The instrumentation hook. More... | |
uint32_t | magic_n = {MAGIC_N} |
Public Attributes inherited from latch_t | |
latch_id_t | m_id |
Latch ID. More... | |
bool | m_rw_lock |
true if it is a rw-lock. More... | |
bool | m_temp_fsp |
true if it is an temporary space latch More... | |
Static Public Attributes | |
static const uint32_t | MAGIC_N = 22643 |
For checking memory corruption. More... | |
The structure used in the spin lock implementation of a read-write lock.
Several threads may have a shared lock simultaneously in this lock, but only one writer may have an exclusive lock, in which case no shared locks are allowed. To prevent starving of a writer blocked by readers, a writer may queue for x-lock by decrementing lock_word: no new readers will be let in while the thread waits for readers to exit.
|
default |
|
delete |
rw_lock_t is not a copyable object, the reasoning behind this is the same as the reasoning behind why std::mutex is not copyable.
It is supposed to represent a synchronization primitive for which copying semantics do not make sense.
|
override |
Destructor.
|
inline |
Checks if there is a thread requesting an x-latch waiting for threads to release their s-latches.
|
overridevirtual |
|
overridevirtual |
|
inline |
In the debug version: pointer to the debug info list of the lock.
rw_lock_t::UT_LIST_NODE_T | ( | rw_lock_t | ) |
All allocated rw locks are put into a list.
ut::Location rw_lock_t::clocation |
Location where lock created.
uint32_t rw_lock_t::count_os_wait |
Count of os_waits.
May not be accurate
os_event_t rw_lock_t::event |
Used by sync0arr.cc for thread queueing.
bool rw_lock_t::is_block_lock |
If 1 then the rw-lock is a block lock.
const char* rw_lock_t::last_s_file_name |
last s-lock file/line is not guaranteed to be correct
uint16_t rw_lock_t::last_s_line |
Line number where last time s-locked.
const char* rw_lock_t::last_x_file_name |
File name where last x-locked.
uint16_t rw_lock_t::last_x_line |
Line number where last time x-locked.
std::atomic<int32_t> rw_lock_t::lock_word |
Holds the state of the lock.
|
static |
For checking memory corruption.
uint32_t rw_lock_t::magic_n = {MAGIC_N} |
struct PSI_rwlock* rw_lock_t::pfs_psi |
The instrumentation hook.
Atomic_xor_of_thread_id rw_lock_t::reader_thread |
XOR of reader threads' IDs.
If there is exactly one reader it should allow to retrieve the thread ID of that reader.
std::atomic<bool> rw_lock_t::recursive |
Default value false which means the lock is non-recursive.
The value is typically set to true making normal rw_locks recursive. In case of asynchronous IO, when a non-zero value of 'pass' is passed then we keep the lock non-recursive.
This flag also tells us about the state of writer_thread field. If this flag is set then writer_thread MUST contain the thread id of the current x-holder or wait-x thread. This flag must be reset in x_unlock functions before incrementing the lock_word
volatile ulint rw_lock_t::sx_recursive |
number of granted SX locks.
os_event_t rw_lock_t::wait_ex_event |
Event for next-writer to wait on.
A thread must decrement lock_word before waiting.
std::atomic<bool> rw_lock_t::waiters |
1: there are waiters
std::atomic<std::thread::id> rw_lock_t::writer_thread |
Thread id of writer thread.
Is only guaranteed to have non-stale value if recursive flag is set, otherwise it may contain native thread ID of a thread which already released or passed the lock.