MySQL 8.3.0
Source Code Documentation
ut0mutex.h File Reference

Policy based mutexes. More...

#include "my_inttypes.h"
#include <set>
#include "ib0mutex.h"
#include "os0atomic.h"
#include "sync0policy.h"
#include "ut0mutex.ic"

Go to the source code of this file.

Classes

struct  IB_mutex_guard
 
class  MutexMonitor
 Iterate over the mutex meta data. More...
 
class  IB_mutex
 

Macros

#define UT_MUTEX_TYPE(M, P, T)   typedef PolicyMutex<M<P>> T;
 Create a typedef using the MutexType<PolicyType> More...
 
#define mutex_create(I, M)   mutex_init((M), (I), __FILE__, __LINE__)
 
#define mutex_enter(M)   mutex_enter_inline(M, UT_LOCATION_HERE)
 
#define mutex_enter_nospin(M)   (M)->enter(0, 0, __FILE__, __LINE__)
 
#define mutex_enter_nowait(M)   (M)->trylock(__FILE__, __LINE__)
 
#define mutex_exit(M)   (M)->exit()
 
#define mutex_free(M)   mutex_destroy(M)
 
#define mutex_validate(M)   (M)->validate()
 Checks that the mutex has been initialized. More...
 
#define mutex_own(M)   (M)->is_owned()
 Checks that the current thread owns the mutex. More...
 

Typedefs

typedef OSMutex EventMutex
 

Functions

template<typename Mutex >
void mutex_enter_inline (Mutex *m, ut::Location loc)
 
template<typename Mutex >
void mutex_init (Mutex *mutex, latch_id_t id, const char *file_name, uint32_t line)
 Creates, or rather, initializes a mutex object in a specified memory location (which must be appropriately aligned). More...
 
template<typename Mutex >
void mutex_destroy (Mutex *mutex)
 Removes a mutex instance from the mutex list. More...
 

Variables

ulong srv_spin_wait_delay
 
ulong srv_n_spin_wait_rounds
 
ulong srv_force_recovery_crash
 Inject a crash at different steps of the recovery process. More...
 
MutexMonitormutex_monitor
 Defined in sync0sync.cc. More...
 

Detailed Description

Policy based mutexes.

Created 2012-03-24 Sunny Bains.

Macro Definition Documentation

◆ mutex_create

#define mutex_create (   I,
  M 
)    mutex_init((M), (I), __FILE__, __LINE__)

◆ mutex_enter

#define mutex_enter (   M)    mutex_enter_inline(M, UT_LOCATION_HERE)

◆ mutex_enter_nospin

#define mutex_enter_nospin (   M)    (M)->enter(0, 0, __FILE__, __LINE__)

◆ mutex_enter_nowait

#define mutex_enter_nowait (   M)    (M)->trylock(__FILE__, __LINE__)

◆ mutex_exit

#define mutex_exit (   M)    (M)->exit()

◆ mutex_free

#define mutex_free (   M)    mutex_destroy(M)

◆ mutex_own

#define mutex_own (   M)    (M)->is_owned()

Checks that the current thread owns the mutex.

Works only in the debug version.

◆ mutex_validate

#define mutex_validate (   M)    (M)->validate()

Checks that the mutex has been initialized.

◆ UT_MUTEX_TYPE

#define UT_MUTEX_TYPE (   M,
  P,
 
)    typedef PolicyMutex<M<P>> T;

Create a typedef using the MutexType<PolicyType>

Parameters
[in]MMutex type
[in]PPolicy type
[in]TThe resulting typedef alias

Typedef Documentation

◆ EventMutex

Function Documentation

◆ mutex_destroy()

template<typename Mutex >
void mutex_destroy ( Mutex *  mutex)

Removes a mutex instance from the mutex list.

The mutex is checked to be in the reset state.

Parameters
[in,out]mutexmutex instance to destroy

◆ mutex_enter_inline()

template<typename Mutex >
void mutex_enter_inline ( Mutex *  m,
ut::Location  loc 
)

◆ mutex_init()

template<typename Mutex >
void mutex_init ( Mutex *  mutex,
latch_id_t  id,
const char *  file_name,
uint32_t  line 
)

Creates, or rather, initializes a mutex object in a specified memory location (which must be appropriately aligned).

The mutex is initialized in the reset state. Explicit freeing of the mutex with mutex_free is necessary only if the memory block containing it is freed. Add the mutex instance to the global mutex list.

Parameters
[in,out]mutexmutex to initialise
[in]idThe mutex ID (Latch ID)
[in]file_nameFilename from where it was called
[in]lineLine number in filename from where called

Variable Documentation

◆ mutex_monitor

MutexMonitor* mutex_monitor
extern

Defined in sync0sync.cc.

Defined in sync0sync.cc.

◆ srv_force_recovery_crash

ulong srv_force_recovery_crash
extern

Inject a crash at different steps of the recovery process.

This is for testing and debugging only.

◆ srv_n_spin_wait_rounds

ulong srv_n_spin_wait_rounds
extern

◆ srv_spin_wait_delay

ulong srv_spin_wait_delay
extern