MySQL 8.4.2
Source Code Documentation
Partitioned_rwlock Class Reference

Implementation of read-write lock partitioned by thread id. More...

#include <partitioned_rwlock.h>

Public Member Functions

 Partitioned_rwlock ()=default
 
bool init (uint parts, PSI_rwlock_key psi_key)
 
void destroy ()
 
void wrlock ()
 
void wrunlock ()
 
void rdlock (uint thread_id)
 
void rdunlock (uint thread_id)
 

Private Member Functions

 Partitioned_rwlock (const Partitioned_rwlock &)
 
Partitioned_rwlockoperator= (const Partitioned_rwlock &)
 

Private Attributes

mysql_rwlock_tm_locks_array
 
uint m_parts
 

Detailed Description

Implementation of read-write lock partitioned by thread id.

This rwlock provides better scalability in read-heavy environments by employing the following simple trick: ) Read lock is acquired only on one of its partitions. The specific partition is chosen according to thread id. ) Write lock is acquired on all partitions.

This way concurrent request for read lock made by different threads have a good chance not to disturb each other by doing cache invalidation and atomic operations. As result scalability in this scenario improves. OTOH acquisition of write lock becomes more expensive. So this rwlock is not supposed to be used in cases when number of write requests is significant.

Constructor & Destructor Documentation

◆ Partitioned_rwlock() [1/2]

Partitioned_rwlock::Partitioned_rwlock ( )
default

◆ Partitioned_rwlock() [2/2]

Partitioned_rwlock::Partitioned_rwlock ( const Partitioned_rwlock )
private

Member Function Documentation

◆ destroy()

void Partitioned_rwlock::destroy ( )
inline

◆ init()

bool Partitioned_rwlock::init ( uint  parts,
PSI_rwlock_key  psi_key 
)
inline
Parameters
partsNumber of partitions.
psi_keyP_S instrumentation key to use for rwlock instances for partitions.

◆ operator=()

Partitioned_rwlock & Partitioned_rwlock::operator= ( const Partitioned_rwlock )
private

◆ rdlock()

void Partitioned_rwlock::rdlock ( uint  thread_id)
inline

◆ rdunlock()

void Partitioned_rwlock::rdunlock ( uint  thread_id)
inline

◆ wrlock()

void Partitioned_rwlock::wrlock ( )
inline

◆ wrunlock()

void Partitioned_rwlock::wrunlock ( )
inline

Member Data Documentation

◆ m_locks_array

mysql_rwlock_t* Partitioned_rwlock::m_locks_array
private

◆ m_parts

uint Partitioned_rwlock::m_parts
private

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