44#ifndef sync0sharded_rw_h
45#define sync0sharded_rw_h
81 static_cast<void>(latch_id);
97 const size_t shard_no =
98 default_indexer_t<>::get_rnd_index() & (
m_n_shards - 1);
113 return m_shards[shard_no].is_x_blocked_by_s();
121 for (
size_t shard_no = 0; shard_no <
m_n_shards; ++shard_no) {
123 while (0 < shard_no--) {
153 template <
typename F>
178 size_t s_lock() {
return 0; }
Rw-lock with very fast, highly concurrent s-lock but slower x-lock.
Definition: sync0sharded_rw.h:63
bool s_own(size_t shard_no) const
Definition: sync0sharded_rw.h:143
void x_unlock()
Definition: sync0sharded_rw.h:138
size_t s_lock(ut::Location location)
Definition: sync0sharded_rw.h:96
void s_unlock(size_t shard_no)
Definition: sync0sharded_rw.h:103
bool x_own() const
Definition: sync0sharded_rw.h:147
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:120
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:111
void for_each(F f)
Definition: sync0sharded_rw.h:154
void free()
Definition: sync0sharded_rw.h:86
void create(mysql_pfs_key_t pfs_key, latch_id_t latch_id, size_t n_shards)
Definition: sync0sharded_rw.h:65
Shard * m_shards
Definition: sync0sharded_rw.h:158
size_t m_n_shards
Definition: sync0sharded_rw.h:160
void x_lock(ut::Location location)
Definition: sync0sharded_rw.h:132
void for_each(const Shards< COUNT > &shards, Function &&f) noexcept
Iterate over the shards.
Definition: ut0counter.h:323
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79
void * zalloc_withkey(PSI_memory_key_t key, std::size_t size) noexcept
Dynamically allocates zero-initialized storage of given size.
Definition: ut0new.h:632
void free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc*(),...
Definition: ut0new.h:717
Define for performance schema registration key.
Definition: sync0sync.h:51
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:360
A utility wrapper class, which adds padding at the end of the wrapped structure, so that the next obj...
Definition: ut0cpu_cache.h:55
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:858
static void rw_lock_s_unlock(rw_lock_t *L)
Definition: sync0rw.h:792
static void rw_lock_x_lock_gen(rw_lock_t *M, ulint P, ut::Location L)
Definition: sync0rw.h:770
static bool rw_lock_x_lock_nowait(rw_lock_t *M, ut::Location L)
Definition: sync0rw.h:774
#define rw_lock_create(K, L, ID)
Definition: sync0rw.h:704
static void rw_lock_x_unlock(rw_lock_t *L)
Definition: sync0rw.h:795
static void rw_lock_s_lock_gen(rw_lock_t *M, ulint P, ut::Location L)
Definition: sync0rw.h:719
static void rw_lock_free(rw_lock_t *M)
Definition: sync0rw.h:788
latch_id_t
Each latch has an ID.
Definition: sync0types.h:342
@ RW_LOCK_S
Definition: sync0types.h:208
@ RW_LOCK_X
Definition: sync0types.h:209
#define UNIV_PFS_RWLOCK
Definition: univ.i:137
Utilities related to CPU cache.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:69
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:57
#define UT_NEW_THIS_FILE_PSI_KEY
Definition: ut0new.h:564
Random numbers and hashing.
#define ut_is_2pow(n)
Determines if a number is zero or a power of two.
Definition: ut0ut.h:197