MySQL 8.4.0
Source Code Documentation
sync0rw.h File Reference

The read-write lock (for threads, not for database transactions) More...

#include <atomic>
#include <cstdint>
#include "univ.i"
#include "os0event.h"
#include "ut0counter.h"
#include "ut0mutex.h"
#include "sync0rw.ic"

Go to the source code of this file.

Classes

struct  rw_lock_debug_t
 The structure for storing debug info of an rw-lock. More...
 
struct  rw_lock_t
 The structure used in the spin lock implementation of a read-write lock. More...
 

Macros

#define rw_lock_create(K, L, ID)    pfs_rw_lock_create_func((K), (L), (ID), UT_LOCATION_HERE)
 

Enumerations

enum  rw_lock_type_t { RW_S_LATCH = 1 , RW_X_LATCH = 2 , RW_SX_LATCH = 4 , RW_NO_LATCH = 8 }
 

Functions

void rw_lock_create_func (rw_lock_t *lock, latch_id_t id, ut::Location clocation)
 Creates, or rather, initializes an rw-lock object in a specified memory location (which must be appropriately aligned). More...
 
void rw_lock_free_func (rw_lock_t *lock)
 Calling this function is obligatory only if the memory buffer containing the rw-lock is freed. More...
 
bool rw_lock_validate (const rw_lock_t *lock)
 Checks that the rw-lock has been initialized and that there are no simultaneous shared and exclusive locks. More...
 
static bool rw_lock_s_lock_low (rw_lock_t *lock, ulint pass, ut::Location location)
 Low-level function which tries to lock an rw-lock in s-mode. More...
 
static void rw_lock_s_lock_func (rw_lock_t *lock, ulint pass, ut::Location location)
 NOTE! Use the corresponding macro, not directly this function, except if you supply the file name and line number. More...
 
static bool rw_lock_x_lock_func_nowait (rw_lock_t *lock, ut::Location location)
 NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for the current thread if the lock can be obtained immediately. More...
 
static void rw_lock_s_unlock_func (ulint pass, rw_lock_t *lock)
 Releases a shared mode lock. More...
 
void rw_lock_x_lock_func (rw_lock_t *lock, ulint pass, ut::Location location)
 NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for the current thread. More...
 
bool rw_lock_sx_lock_low (rw_lock_t *lock, ulint pass, ut::Location location)
 Low-level function for acquiring an sx lock. More...
 
void rw_lock_sx_lock_func (rw_lock_t *lock, ulint pass, ut::Location location)
 NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in SX mode for the current thread. More...
 
static void rw_lock_x_unlock_func (ulint pass, rw_lock_t *lock)
 Releases an exclusive mode lock. More...
 
static void rw_lock_sx_unlock_func (ulint pass, rw_lock_t *lock)
 Releases an sx mode lock. More...
 
void rw_lock_x_lock_move_ownership (rw_lock_t *lock)
 This function is used in the insert buffer to move the ownership of an x-latch on a buffer frame to the current thread. More...
 
static ulint rw_lock_get_x_lock_count (const rw_lock_t *lock)
 Returns the value of writer_count for the lock. More...
 
static ulint rw_lock_get_sx_lock_count (const rw_lock_t *lock)
 Returns the number of sx-lock for the lock. More...
 
static bool rw_lock_get_waiters (const rw_lock_t *lock)
 Check if there are threads waiting for the rw-lock. More...
 
static ulint rw_lock_get_writer (const rw_lock_t *lock)
 Returns the write-status of the lock - this function made more sense with the old rw_lock implementation. More...
 
static ulint rw_lock_get_reader_count (const rw_lock_t *lock)
 Returns the number of readers (s-locks). More...
 
static bool rw_lock_lock_word_decr (rw_lock_t *lock, ulint amount, lint threshold)
 Decrements lock_word the specified amount if it is greater than 0. More...
 
static lint rw_lock_lock_word_incr (rw_lock_t *lock, ulint amount)
 Increments lock_word the specified amount and returns new value. More...
 
static void rw_lock_set_writer_id_and_recursion_flag (rw_lock_t *lock, bool recursive)
 This function sets the lock->writer_thread and lock->recursive fields. More...
 
bool rw_lock_own (const rw_lock_t *lock, ulint lock_type)
 Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0. More...
 
bool rw_lock_own_flagged (const rw_lock_t *lock, rw_lock_flags_t flags)
 Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0. More...
 
bool rw_lock_is_locked (rw_lock_t *lock, ulint lock_type)
 Checks if somebody has locked the rw-lock in the specified mode. More...
 
void rw_lock_list_print_info (FILE *file)
 Prints debug info of currently locked rw-locks. More...
 
void rw_lock_debug_print (FILE *f, const rw_lock_debug_t *info)
 Prints info of a debug struct. More...
 
static void pfs_rw_lock_create_func (mysql_pfs_key_t key, rw_lock_t *lock, latch_id_t id, ut::Location clocation)
 Performance schema instrumented wrap function for rw_lock_create_func() NOTE! Please use the corresponding macro rw_lock_create(), not directly this function! More...
 
static void pfs_rw_lock_x_lock_func (rw_lock_t *lock, ulint pass, ut::Location location)
 Performance schema instrumented wrap function for rw_lock_x_lock_func() NOTE! Please use the corresponding macro rw_lock_x_lock(), not directly this function! More...
 
static bool pfs_rw_lock_x_lock_func_nowait (rw_lock_t *lock, ut::Location location)
 Performance schema instrumented wrap function for rw_lock_x_lock_func_nowait() NOTE! Please use the corresponding macro, not directly this function! More...
 
static void pfs_rw_lock_s_lock_func (rw_lock_t *lock, ulint pass, ut::Location location)
 Performance schema instrumented wrap function for rw_lock_s_lock_func() NOTE! Please use the corresponding macro rw_lock_s_lock(), not directly this function! More...
 
static bool pfs_rw_lock_s_lock_low (rw_lock_t *lock, ulint pass, ut::Location location)
 Performance schema instrumented wrap function for rw_lock_s_lock_func() NOTE! Please use the corresponding macro rw_lock_s_lock(), not directly this function! More...
 
static void pfs_rw_lock_s_unlock_func (ulint pass, rw_lock_t *lock)
 Performance schema instrumented wrap function for rw_lock_s_unlock_func() NOTE! Please use the corresponding macro rw_lock_s_unlock(), not directly this function! More...
 
static void pfs_rw_lock_x_unlock_func (ulint pass, rw_lock_t *lock)
 Performance schema instrumented wrap function for rw_lock_x_unlock_func() NOTE! Please use the corresponding macro rw_lock_x_unlock(), not directly this function! More...
 
static void pfs_rw_lock_sx_lock_func (rw_lock_t *lock, ulint pass, ut::Location location)
 Performance schema instrumented wrap function for rw_lock_sx_lock_func() NOTE! Please use the corresponding macro rw_lock_sx_lock(), not directly this function! More...
 
static bool pfs_rw_lock_sx_lock_low (rw_lock_t *lock, ulint pass, ut::Location location)
 Performance schema instrumented wrap function for rw_lock_sx_lock_nowait() NOTE! Please use the corresponding macro, not directly this function! More...
 
static void pfs_rw_lock_sx_unlock_func (ulint pass, rw_lock_t *lock)
 Performance schema instrumented wrap function for rw_lock_sx_unlock_func() NOTE! Please use the corresponding macro rw_lock_sx_unlock(), not directly this function! More...
 
static void pfs_rw_lock_free_func (rw_lock_t *lock)
 Performance schema instrumented wrap function for rw_lock_free_func() NOTE! Please use the corresponding macro rw_lock_free(), not directly this function! More...
 
static void rw_lock_s_lock (rw_lock_t *M, ut::Location L)
 
static void rw_lock_s_lock_gen (rw_lock_t *M, ulint P, ut::Location L)
 
static bool rw_lock_s_lock_nowait (rw_lock_t *M, ut::Location L)
 
static void rw_lock_s_unlock_gen (rw_lock_t *L, ulint P)
 
static void rw_lock_sx_lock (rw_lock_t *M, ut::Location L)
 
static void rw_lock_sx_lock_gen (rw_lock_t *M, ulint P, ut::Location L)
 
static bool rw_lock_sx_lock_nowait (rw_lock_t *M, ulint P, ut::Location L)
 
static void rw_lock_sx_unlock (rw_lock_t *L)
 
static void rw_lock_sx_unlock_gen (rw_lock_t *L, ulint P)
 
static void rw_lock_x_lock (rw_lock_t *M, ut::Location L)
 
static void rw_lock_x_lock_gen (rw_lock_t *M, ulint P, ut::Location L)
 
static bool rw_lock_x_lock_nowait (rw_lock_t *M, ut::Location L)
 
static void rw_lock_x_unlock_gen (rw_lock_t *L, ulint P)
 
static void rw_lock_free (rw_lock_t *M)
 
static void rw_lock_s_unlock (rw_lock_t *L)
 
static void rw_lock_x_unlock (rw_lock_t *L)
 
typedef UT_LIST_BASE_NODE_T (rw_lock_t, list) rw_lock_list_t
 

Variables

constexpr int32_t X_LOCK_DECR = 0x20000000
 
constexpr int32_t X_LOCK_HALF_DECR = 0x10000000
 
ib_mutex_t rw_lock_list_mutex
 
rw_lock_list_t rw_lock_list
 The global list of rw-locks. More...
 

Detailed Description

The read-write lock (for threads, not for database transactions)

Created 9/11/1995 Heikki Tuuri

Macro Definition Documentation

◆ rw_lock_create

#define rw_lock_create (   K,
  L,
  ID 
)     pfs_rw_lock_create_func((K), (L), (ID), UT_LOCATION_HERE)

Enumeration Type Documentation

◆ rw_lock_type_t

Enumerator
RW_S_LATCH 
RW_X_LATCH 
RW_SX_LATCH 
RW_NO_LATCH 

Function Documentation

◆ pfs_rw_lock_create_func()

static void pfs_rw_lock_create_func ( mysql_pfs_key_t  key,
rw_lock_t lock,
latch_id_t  id,
ut::Location  clocation 
)
inlinestatic

Performance schema instrumented wrap function for rw_lock_create_func() NOTE! Please use the corresponding macro rw_lock_create(), not directly this function!

Parameters
[in]keykey registered with performance schema
[in]lockrw lock
[in]idlatch_id
[in]clocationlocation where created

◆ pfs_rw_lock_free_func()

static void pfs_rw_lock_free_func ( rw_lock_t lock)
inlinestatic

Performance schema instrumented wrap function for rw_lock_free_func() NOTE! Please use the corresponding macro rw_lock_free(), not directly this function!

in: rw-lock

◆ pfs_rw_lock_s_lock_func()

static void pfs_rw_lock_s_lock_func ( rw_lock_t lock,
ulint  pass,
ut::Location  location 
)
inlinestatic

Performance schema instrumented wrap function for rw_lock_s_lock_func() NOTE! Please use the corresponding macro rw_lock_s_lock(), not directly this function!

Parameters
[in]lockpointer to rw-lock
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in]locationlocation where requested

◆ pfs_rw_lock_s_lock_low()

static bool pfs_rw_lock_s_lock_low ( rw_lock_t lock,
ulint  pass,
ut::Location  location 
)
inlinestatic

Performance schema instrumented wrap function for rw_lock_s_lock_func() NOTE! Please use the corresponding macro rw_lock_s_lock(), not directly this function!

Parameters
[in]lockpointer to rw-lock
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in]locationlocation where requested
Returns
true if success

◆ pfs_rw_lock_s_unlock_func()

static void pfs_rw_lock_s_unlock_func ( ulint  pass,
rw_lock_t lock 
)
inlinestatic

Performance schema instrumented wrap function for rw_lock_s_unlock_func() NOTE! Please use the corresponding macro rw_lock_s_unlock(), not directly this function!

Parameters
[in]passpass value; != 0, if the lock may have been passed to another thread to unlock
[in,out]lockrw-lock

◆ pfs_rw_lock_sx_lock_func()

static void pfs_rw_lock_sx_lock_func ( rw_lock_t lock,
ulint  pass,
ut::Location  location 
)
inlinestatic

Performance schema instrumented wrap function for rw_lock_sx_lock_func() NOTE! Please use the corresponding macro rw_lock_sx_lock(), not directly this function!

Parameters
[in]lockpointer to rw-lock
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in]locationlocation where requested

◆ pfs_rw_lock_sx_lock_low()

static bool pfs_rw_lock_sx_lock_low ( rw_lock_t lock,
ulint  pass,
ut::Location  location 
)
inlinestatic

Performance schema instrumented wrap function for rw_lock_sx_lock_nowait() NOTE! Please use the corresponding macro, not directly this function!

Parameters
[in]lockpointer to rw-lock
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in]locationlocation where requested

◆ pfs_rw_lock_sx_unlock_func()

static void pfs_rw_lock_sx_unlock_func ( ulint  pass,
rw_lock_t lock 
)
inlinestatic

Performance schema instrumented wrap function for rw_lock_sx_unlock_func() NOTE! Please use the corresponding macro rw_lock_sx_unlock(), not directly this function!

Parameters
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in,out]lockpointer to rw-lock

◆ pfs_rw_lock_x_lock_func()

static void pfs_rw_lock_x_lock_func ( rw_lock_t lock,
ulint  pass,
ut::Location  location 
)
inlinestatic

Performance schema instrumented wrap function for rw_lock_x_lock_func() NOTE! Please use the corresponding macro rw_lock_x_lock(), not directly this function!

Parameters
[in]lockpointer to rw-lock
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in]locationlocation where requested

◆ pfs_rw_lock_x_lock_func_nowait()

static bool pfs_rw_lock_x_lock_func_nowait ( rw_lock_t lock,
ut::Location  location 
)
inlinestatic

Performance schema instrumented wrap function for rw_lock_x_lock_func_nowait() NOTE! Please use the corresponding macro, not directly this function!

Parameters
[in]lockpointer to rw-lock
[in]locationlocation where requested
Returns
true if success

◆ pfs_rw_lock_x_unlock_func()

static void pfs_rw_lock_x_unlock_func ( ulint  pass,
rw_lock_t lock 
)
inlinestatic

Performance schema instrumented wrap function for rw_lock_x_unlock_func() NOTE! Please use the corresponding macro rw_lock_x_unlock(), not directly this function!

Parameters
[in]passpass value; != 0, if the lock may have been passed to another thread to unlock
[in,out]lockrw-lock

◆ rw_lock_create_func()

void rw_lock_create_func ( rw_lock_t lock,
latch_id_t  id,
ut::Location  clocation 
)

Creates, or rather, initializes an rw-lock object in a specified memory location (which must be appropriately aligned).

The rw-lock is initialized to the non-locked state. Explicit freeing of the rw-lock with rw_lock_free is necessary only if the memory block containing it is freed.

Parameters
[in]lockpointer to memory
[in]idlatch_id
[in]clocationlocation where created

◆ rw_lock_debug_print()

void rw_lock_debug_print ( FILE *  f,
const rw_lock_debug_t info 
)

Prints info of a debug struct.

Parameters
[in]fOutput stream
[in]infoDebug struct

◆ rw_lock_free()

static void rw_lock_free ( rw_lock_t M)
inlinestatic

◆ rw_lock_free_func()

void rw_lock_free_func ( rw_lock_t lock)

Calling this function is obligatory only if the memory buffer containing the rw-lock is freed.

Removes an rw-lock object from the global list. The rw-lock is checked to be in the non-locked state. in/out: rw-lock

Removes an rw-lock object from the global list. The rw-lock is checked to be in the non-locked state.

Parameters
lockin/out: rw-lock

◆ rw_lock_get_reader_count()

static ulint rw_lock_get_reader_count ( const rw_lock_t lock)
inlinestatic

Returns the number of readers (s-locks).

Parameters
[in]lockrw-lock
Returns
number of readers

◆ rw_lock_get_sx_lock_count()

static ulint rw_lock_get_sx_lock_count ( const rw_lock_t lock)
inlinestatic

Returns the number of sx-lock for the lock.

Does not reserve the lock mutex, so the caller must be sure it is not changed during the call.

Parameters
[in]lockrw-lock
Returns
value of writer_count

◆ rw_lock_get_waiters()

static bool rw_lock_get_waiters ( const rw_lock_t lock)
inlinestatic

Check if there are threads waiting for the rw-lock.

Parameters
[in]lockrw-lock
Returns
true if waiters, false otherwise

◆ rw_lock_get_writer()

static ulint rw_lock_get_writer ( const rw_lock_t lock)
inlinestatic

Returns the write-status of the lock - this function made more sense with the old rw_lock implementation.

Parameters
[in]lockrw-lock
Returns
RW_LOCK_NOT_LOCKED, RW_LOCK_X, RW_LOCK_X_WAIT, RW_LOCK_SX

◆ rw_lock_get_x_lock_count()

static ulint rw_lock_get_x_lock_count ( const rw_lock_t lock)
inlinestatic

Returns the value of writer_count for the lock.

Does not reserve the lock mutex, so the caller must be sure it is not changed during the call.

Returns
value of writer_count
Parameters
[in]lockrw-lock

◆ rw_lock_is_locked()

bool rw_lock_is_locked ( rw_lock_t lock,
ulint  lock_type 
)

Checks if somebody has locked the rw-lock in the specified mode.

Parameters
[in]lockthe rw-lock
[in]lock_typeThe exact lock type to check: RW_LOCK_S, RW_LOCK_SX or RW_LOCK_X
Returns
true if locked
true if locked
Parameters
lockin: rw-lock
lock_typein: lock type: RW_LOCK_S, RW_LOCK_X or RW_LOCK_SX

◆ rw_lock_list_print_info()

void rw_lock_list_print_info ( FILE *  file)

Prints debug info of currently locked rw-locks.

Parameters
[in]filefile where to print
Parameters
filein: file where to print

◆ rw_lock_lock_word_decr()

static bool rw_lock_lock_word_decr ( rw_lock_t lock,
ulint  amount,
lint  threshold 
)
inlinestatic

Decrements lock_word the specified amount if it is greater than 0.

This is used by both s_lock and x_lock operations.

Parameters
[in,out]lockrw-lock
[in]amountamount to decrement
[in]thresholdthreshold of judgement
Returns
true if decr occurs

Decrements lock_word the specified amount if it is greater than 0.

This does does not support recursive x-locks: they should be handled by the caller and need not be atomic since they are performed by the current lock holder. Returns true if the decrement was made, false if not.

Returns
true if decr occurs
Parameters
lockin/out: rw-lock
amountin: amount to decrement
thresholdin: threshold of judgement

◆ rw_lock_lock_word_incr()

static lint rw_lock_lock_word_incr ( rw_lock_t lock,
ulint  amount 
)
inlinestatic

Increments lock_word the specified amount and returns new value.

Parameters
[in,out]lockrw-lock
[in]amountamount to decrement
Returns
lock->lock_word after increment

◆ rw_lock_own()

bool rw_lock_own ( const rw_lock_t lock,
ulint  lock_type 
)

Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0.

Note that the mode is checked exactly, so if the thread owns RW_LOCK_X only, the rw_lock_own(..,RW_LOCK_S) will return false.

Parameters
[in]lockthe rw-lock
[in]lock_typeThe exact lock type to check: RW_LOCK_S, RW_LOCK_SX or RW_LOCK_X

◆ rw_lock_own_flagged()

bool rw_lock_own_flagged ( const rw_lock_t lock,
rw_lock_flags_t  flags 
)

Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0.

Parameters
[in]lockrw-lock
[in]flagsspecify lock types with OR of the rw_lock_flag_t values
Returns
true if locked

◆ rw_lock_s_lock()

static void rw_lock_s_lock ( rw_lock_t M,
ut::Location  L 
)
inlinestatic

◆ rw_lock_s_lock_func()

static void rw_lock_s_lock_func ( rw_lock_t lock,
ulint  pass,
ut::Location  location 
)
inlinestatic

NOTE! Use the corresponding macro, not directly this function, except if you supply the file name and line number.

Lock an rw-lock in shared mode for the current thread. If the rw-lock is locked in exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by srv_n_spin_wait_rounds), waiting for the lock, before suspending the thread.

Parameters
[in]lockpointer to rw-lock
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in]locationlocation where requested

◆ rw_lock_s_lock_gen()

static void rw_lock_s_lock_gen ( rw_lock_t M,
ulint  P,
ut::Location  L 
)
inlinestatic

◆ rw_lock_s_lock_low()

static bool rw_lock_s_lock_low ( rw_lock_t lock,
ulint  pass,
ut::Location  location 
)
inlinestatic

Low-level function which tries to lock an rw-lock in s-mode.

Performs no spinning.

Parameters
[in]lockpointer to rw-lock
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in]locationlocation where requested
Returns
true if success

◆ rw_lock_s_lock_nowait()

static bool rw_lock_s_lock_nowait ( rw_lock_t M,
ut::Location  L 
)
inlinestatic

◆ rw_lock_s_unlock()

static void rw_lock_s_unlock ( rw_lock_t L)
inlinestatic

◆ rw_lock_s_unlock_func()

static void rw_lock_s_unlock_func ( ulint  pass,
rw_lock_t lock 
)
inlinestatic

Releases a shared mode lock.

Parameters
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in,out]lockrw-lock

◆ rw_lock_s_unlock_gen()

static void rw_lock_s_unlock_gen ( rw_lock_t L,
ulint  P 
)
inlinestatic

◆ rw_lock_set_writer_id_and_recursion_flag()

static void rw_lock_set_writer_id_and_recursion_flag ( rw_lock_t lock,
bool  recursive 
)
inlinestatic

This function sets the lock->writer_thread and lock->recursive fields.

Sets lock->recursive field using atomic release after setting lock->writer thread to ensure proper memory ordering of the two. Note that it is assumed that the caller of this function effectively owns the lock i.e.: nobody else is allowed to modify lock->writer_thread at this point in time. The protocol is that lock->writer_thread MUST be updated BEFORE the lock->recursive flag is set.

Parameters
[in,out]locklock to work on
[in]recursivetrue if recursion allowed

◆ rw_lock_sx_lock()

static void rw_lock_sx_lock ( rw_lock_t M,
ut::Location  L 
)
inlinestatic

◆ rw_lock_sx_lock_func()

void rw_lock_sx_lock_func ( rw_lock_t lock,
ulint  pass,
ut::Location  location 
)

NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in SX mode for the current thread.

If the rw-lock is locked in exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by SYNC_SPIN_ROUNDS), waiting for the lock, before suspending the thread. If the same thread has an x-lock on the rw-lock, locking succeed, with the following exception: if pass != 0, only a single sx-lock may be taken on the lock. NOTE: If the same thread has an s-lock, locking does not succeed!

Parameters
[in]lockpointer to rw-lock
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in]locationlocation where requested

◆ rw_lock_sx_lock_gen()

static void rw_lock_sx_lock_gen ( rw_lock_t M,
ulint  P,
ut::Location  L 
)
inlinestatic

◆ rw_lock_sx_lock_low()

bool rw_lock_sx_lock_low ( rw_lock_t lock,
ulint  pass,
ut::Location  location 
)

Low-level function for acquiring an sx lock.

Parameters
[in]lockpointer to rw-lock
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in]locationlocation where requested
Returns
false if did not succeed, true if success.

◆ rw_lock_sx_lock_nowait()

static bool rw_lock_sx_lock_nowait ( rw_lock_t M,
ulint  P,
ut::Location  L 
)
inlinestatic

◆ rw_lock_sx_unlock()

static void rw_lock_sx_unlock ( rw_lock_t L)
inlinestatic

◆ rw_lock_sx_unlock_func()

static void rw_lock_sx_unlock_func ( ulint  pass,
rw_lock_t lock 
)
inlinestatic

Releases an sx mode lock.

Parameters
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in,out]lockrw-lock

◆ rw_lock_sx_unlock_gen()

static void rw_lock_sx_unlock_gen ( rw_lock_t L,
ulint  P 
)
inlinestatic

◆ rw_lock_validate()

bool rw_lock_validate ( const rw_lock_t lock)

Checks that the rw-lock has been initialized and that there are no simultaneous shared and exclusive locks.

Returns
true in: rw-lock
true
Parameters
lockin: rw-lock

◆ rw_lock_x_lock()

static void rw_lock_x_lock ( rw_lock_t M,
ut::Location  L 
)
inlinestatic

◆ rw_lock_x_lock_func()

void rw_lock_x_lock_func ( rw_lock_t lock,
ulint  pass,
ut::Location  location 
)

NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for the current thread.

If the rw-lock is locked in shared or exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by srv_n_spin_wait_rounds), waiting for the lock, before suspending the thread. If the same thread has an x-lock on the rw-lock, locking succeed, with the following exception: if pass != 0, only a single x-lock may be taken on the lock. NOTE: If the same thread has an s-lock, locking does not succeed!

Parameters
[in]lockpointer to rw-lock
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in]locationlocation where requested

◆ rw_lock_x_lock_func_nowait()

static bool rw_lock_x_lock_func_nowait ( rw_lock_t lock,
ut::Location  location 
)
inlinestatic

NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for the current thread if the lock can be obtained immediately.

Parameters
[in]lockpointer to rw-lock
[in]locationlocation where requested
Returns
true if success

◆ rw_lock_x_lock_gen()

static void rw_lock_x_lock_gen ( rw_lock_t M,
ulint  P,
ut::Location  L 
)
inlinestatic

◆ rw_lock_x_lock_move_ownership()

void rw_lock_x_lock_move_ownership ( rw_lock_t lock)

This function is used in the insert buffer to move the ownership of an x-latch on a buffer frame to the current thread.

The x-latch was set by the buffer read operation and it protected the buffer frame while the read was done. The ownership is moved because we want that the current thread is able to acquire a second x-latch which is stored in an mtr. This, in turn, is needed to pass the debug checks of index page operations.

Parameters
[in]locklock which was x-locked in the buffer read.

The x-latch was set by the buffer read operation and it protected the buffer frame while the read was done. The ownership is moved because we want that the current thread is able to acquire a second x-latch which is stored in an mtr. This, in turn, is needed to pass the debug checks of index page operations.

Parameters
lockin: lock which was x-locked in the buffer read

◆ rw_lock_x_lock_nowait()

static bool rw_lock_x_lock_nowait ( rw_lock_t M,
ut::Location  L 
)
inlinestatic

◆ rw_lock_x_unlock()

static void rw_lock_x_unlock ( rw_lock_t L)
inlinestatic

◆ rw_lock_x_unlock_func()

static void rw_lock_x_unlock_func ( ulint  pass,
rw_lock_t lock 
)
inlinestatic

Releases an exclusive mode lock.

Parameters
[in]passpass value; != 0, if the lock will be passed to another thread to unlock
[in,out]lockrw-lock

◆ rw_lock_x_unlock_gen()

static void rw_lock_x_unlock_gen ( rw_lock_t L,
ulint  P 
)
inlinestatic

◆ UT_LIST_BASE_NODE_T()

typedef UT_LIST_BASE_NODE_T ( rw_lock_t  ,
list   
)

Variable Documentation

◆ rw_lock_list

rw_lock_list_t rw_lock_list
extern

The global list of rw-locks.

◆ rw_lock_list_mutex

ib_mutex_t rw_lock_list_mutex
extern

◆ X_LOCK_DECR

constexpr int32_t X_LOCK_DECR = 0x20000000
constexpr

◆ X_LOCK_HALF_DECR

constexpr int32_t X_LOCK_HALF_DECR = 0x10000000
constexpr