MySQL 8.0.39
Source Code Documentation
|
Rw-lock with very fast, highly concurrent s-lock but slower x-lock. More...
#include <sync0sharded_rw.h>
Public Member Functions | |
void | create (mysql_pfs_key_t pfs_key, latch_id_t latch_id, size_t n_shards) |
void | free () |
size_t | s_lock (ut::Location location) |
void | s_unlock (size_t shard_no) |
bool | is_x_blocked_by_s (size_t shard_no) |
Checks if there is a thread requesting an x-latch waiting for threads to release their s-latches on given shard. More... | |
bool | try_x_lock (ut::Location location) |
Tries to obtain exclusive latch - similar to x_lock(), but non-blocking, and thus can fail. More... | |
void | x_lock (ut::Location location) |
void | x_unlock () |
bool | s_own (size_t shard_no) const |
bool | x_own () const |
Private Types | |
using | Shard = ut::Cacheline_padded< rw_lock_t > |
Private Member Functions | |
template<typename F > | |
void | for_each (F f) |
Private Attributes | |
Shard * | m_shards = nullptr |
size_t | m_n_shards = 0 |
Rw-lock with very fast, highly concurrent s-lock but slower x-lock.
It's basically array of rw-locks. When s-lock is being acquired, single rw-lock from array is selected randomly and s-locked. Therefore, all rw-locks from array has to be x-locked when x-lock is being acquired.
Purpose of this data structure is to reduce contention on single atomic in single rw-lock when a lot of threads need to acquire s-lock very often, but x-lock is very rare.
|
private |
|
inline |
|
inlineprivate |
|
inline |
|
inline |
Checks if there is a thread requesting an x-latch waiting for threads to release their s-latches on given shard.
[in] | shard_no | The shard to check. |
|
inline |
|
inline |
|
inline |
|
inline |
Tries to obtain exclusive latch - similar to x_lock(), but non-blocking, and thus can fail.
|
inline |
|
inline |
|
inline |
|
private |