MySQL 9.1.0
Source Code Documentation
locksys::Shard_naked_latches_guard Class Reference

A RAII helper which latches the mutexes protecting specified shards for the duration of its scope. More...

#include <lock0guards.h>

Public Member Functions

 Shard_naked_latches_guard (const buf_block_t &block_a, const buf_block_t &block_b)
 
 ~Shard_naked_latches_guard ()
 

Private Member Functions

 Shard_naked_latches_guard (Lock_mutex &shard_mutex_a, Lock_mutex &shard_mutex_b)
 

Private Attributes

Lock_mutexm_shard_mutex_1
 The "smallest" of the two shards' mutexes in the latching order. More...
 
Lock_mutexm_shard_mutex_2
 The "largest" of the two shards' mutexes in the latching order. More...
 

Static Private Attributes

static constexpr std::less< Lock_mutex * > MUTEX_ORDER {}
 The ordering on shard mutexes used to avoid deadlocks. More...
 

Detailed Description

A RAII helper which latches the mutexes protecting specified shards for the duration of its scope.

It makes sure to take the latches in correct order and handles the case where both pages are in the same shard correctly. You quite probably don't want to use this class, which only takes a shard's latch, without acquiring global_latch - which gives no protection from threads which latch only the global_latch exclusively to prevent any activity. You should use it in combination with Global_shared_latch_guard, so that you first obtain an s-latch on the global_latch, or simply use the Shard_latches_guard class which already combines the two for you.

Constructor & Destructor Documentation

◆ Shard_naked_latches_guard() [1/2]

locksys::Shard_naked_latches_guard::Shard_naked_latches_guard ( Lock_mutex shard_mutex_a,
Lock_mutex shard_mutex_b 
)
explicitprivate

◆ Shard_naked_latches_guard() [2/2]

locksys::Shard_naked_latches_guard::Shard_naked_latches_guard ( const buf_block_t block_a,
const buf_block_t block_b 
)
explicit

◆ ~Shard_naked_latches_guard()

locksys::Shard_naked_latches_guard::~Shard_naked_latches_guard ( )

Member Data Documentation

◆ m_shard_mutex_1

Lock_mutex& locksys::Shard_naked_latches_guard::m_shard_mutex_1
private

The "smallest" of the two shards' mutexes in the latching order.

◆ m_shard_mutex_2

Lock_mutex& locksys::Shard_naked_latches_guard::m_shard_mutex_2
private

The "largest" of the two shards' mutexes in the latching order.

◆ MUTEX_ORDER

constexpr std::less<Lock_mutex *> locksys::Shard_naked_latches_guard::MUTEX_ORDER {}
staticconstexprprivate

The ordering on shard mutexes used to avoid deadlocks.


The documentation for this class was generated from the following files: