![]() |
MySQL
8.0.23
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) debug_list | |
In the debug version: pointer to the debug info list of the lock. More... | |
![]() | |
latch_t (latch_id_t id=LATCH_ID_NONE) 1 | |
Constructor. More... | |
latch_t & | operator= (const latch_t &)=default |
virtual | ~latch_t () 1 |
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... | |
bool | writer_is_wait_ex |
This is TRUE if the writer field is RW_LOCK_X_WAIT; this field is located far from the memory update hotspot fields which are at the start of this struct, thus we can peek this field without causing much memory bus traffic. More... | |
volatile ulint | sx_recursive |
number of granted SX locks. More... | |
std::atomic< os_thread_id_t > | writer_thread |
Thread id of writer thread. 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... | |
const char * | cfile_name |
File name 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... | |
uint16_t | cline |
Line where created. 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} |
latch_level_t | level |
Level in the global latching order. More... | |
![]() | |
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.
|
inlineoverride |
Destructor.
|
overridevirtual |
|
overridevirtual |
rw_lock_t::UT_LIST_BASE_NODE_T | ( | rw_lock_debug_t | ) |
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.
const char* rw_lock_t::cfile_name |
File name where lock created.
uint16_t rw_lock_t::cline |
Line where 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.
latch_level_t rw_lock_t::level |
Level in the global latching order.
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.
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
bool rw_lock_t::writer_is_wait_ex |
This is TRUE if the writer field is RW_LOCK_X_WAIT; this field is located far from the memory update hotspot fields which are at the start of this struct, thus we can peek this field without causing much memory bus traffic.
std::atomic<os_thread_id_t> 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 handle of a thread which already released or passed the lock.