43#ifndef sync0sharded_rw_h
44#define sync0sharded_rw_h
80 static_cast<void>(latch_id);
96 const size_t shard_no =
97 default_indexer_t<>::get_rnd_index() & (
m_n_shards - 1);
112 return m_shards[shard_no].is_x_blocked_by_s();
120 for (
size_t shard_no = 0; shard_no <
m_n_shards; ++shard_no) {
122 while (0 < shard_no--) {
152 template <
typename F>
177 size_t s_lock() {
return 0; }
Rw-lock with very fast, highly concurrent s-lock but slower x-lock.
Definition: sync0sharded_rw.h:62
bool s_own(size_t shard_no) const
Definition: sync0sharded_rw.h:142
void x_unlock()
Definition: sync0sharded_rw.h:137
size_t s_lock(ut::Location location)
Definition: sync0sharded_rw.h:95
void s_unlock(size_t shard_no)
Definition: sync0sharded_rw.h:102
bool x_own() const
Definition: sync0sharded_rw.h:146
bool try_x_lock(ut::Location location)
Tries to obtain exclusive latch - similar to x_lock(), but non-blocking, and thus can fail.
Definition: sync0sharded_rw.h:119
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 g...
Definition: sync0sharded_rw.h:110
void for_each(F f)
Definition: sync0sharded_rw.h:153
void free()
Definition: sync0sharded_rw.h:85
void create(mysql_pfs_key_t pfs_key, latch_id_t latch_id, size_t n_shards)
Definition: sync0sharded_rw.h:64
Shard * m_shards
Definition: sync0sharded_rw.h:157
size_t m_n_shards
Definition: sync0sharded_rw.h:159
void x_lock(ut::Location location)
Definition: sync0sharded_rw.h:131
void for_each(const Shards< COUNT > &shards, Function &&f) noexcept
Iterate over the shards.
Definition: ut0counter.h:322
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:78
void * zalloc_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates zero-initialized storage of given size.
Definition: ut0new.h:631
void free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc*(),...
Definition: ut0new.h:716
Define for performance schema registration key.
Definition: sync0sync.h:50
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:359
A utility wrapper class, which adds padding at the end of the wrapped structure, so that the next obj...
Definition: ut0cpu_cache.h:54
The read-write lock (for threads, not for database transactions)
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.
Definition: sync0rw.cc:857
static void rw_lock_s_unlock(rw_lock_t *L)
Definition: sync0rw.h:791
static void rw_lock_x_lock_gen(rw_lock_t *M, ulint P, ut::Location L)
Definition: sync0rw.h:769
static bool rw_lock_x_lock_nowait(rw_lock_t *M, ut::Location L)
Definition: sync0rw.h:773
#define rw_lock_create(K, L, ID)
Definition: sync0rw.h:703
static void rw_lock_x_unlock(rw_lock_t *L)
Definition: sync0rw.h:794
static void rw_lock_s_lock_gen(rw_lock_t *M, ulint P, ut::Location L)
Definition: sync0rw.h:718
static void rw_lock_free(rw_lock_t *M)
Definition: sync0rw.h:787
latch_id_t
Each latch has an ID.
Definition: sync0types.h:341
@ RW_LOCK_S
Definition: sync0types.h:207
@ RW_LOCK_X
Definition: sync0types.h:208
#define UNIV_PFS_RWLOCK
Definition: univ.i:136
Utilities related to CPU cache.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:56
#define UT_NEW_THIS_FILE_PSI_KEY
Definition: ut0new.h:563
Random numbers and hashing.
#define ut_is_2pow(n)
Determines if a number is zero or a power of two.
Definition: ut0ut.h:196