47 ut_a((n_elems >= 2) && ((n_elems & (n_elems - 1)) == 0));
49 for (
size_t i = 0; i < n_elems; ++i) {
50 m_ring[i].
m_pos.store(i, std::memory_order_relaxed);
63 [[nodiscard]]
bool enqueue(T
const &data) {
79 seq = cell->
m_pos.load(std::memory_order_acquire);
81 intptr_t
diff = (intptr_t)seq - (intptr_t)pos;
92 std::memory_order_relaxed)) {
96 }
else if (
diff < 0) {
110 cell->
m_pos.store(pos + 1, std::memory_order_release);
125 size_t seq = cell->
m_pos.load(std::memory_order_acquire);
127 auto diff = (intptr_t)seq - (intptr_t)(pos + 1);
136 std::memory_order_relaxed)) {
140 }
else if (
diff < 0) {
170 size_t seq = cell->
m_pos.load(std::memory_order_acquire);
172 auto diff = (intptr_t)seq - (intptr_t)(pos + 1);
176 }
else if (
diff < 0) {
193 typename std::aligned_storage<
sizeof(
Cell),
194 std::alignment_of<Cell>::value>::
type;
Multiple producer consumer, bounded queue Implementation of Dmitry Vyukov's MPMC algorithm http://www...
Definition: ut0mpmcbq.h:38
Pad m_pad3
Definition: ut0mpmcbq.h:203
size_t const m_capacity
Definition: ut0mpmcbq.h:198
mpmc_bq(const mpmc_bq &)=delete
std::atomic< size_t > m_dequeue_pos
Definition: ut0mpmcbq.h:202
bool empty() const
Definition: ut0mpmcbq.h:164
Pad m_pad2
Definition: ut0mpmcbq.h:201
typename std::aligned_storage< sizeof(Cell), std::alignment_of< Cell >::value >::type Aligned
Definition: ut0mpmcbq.h:194
size_t capacity() const
Definition: ut0mpmcbq.h:161
bool dequeue(T &data)
Dequeue an element.
Definition: ut0mpmcbq.h:118
bool enqueue(T const &data)
Enqueue an element.
Definition: ut0mpmcbq.h:63
mpmc_bq & operator=(const mpmc_bq &)=delete
Pad m_pad0
Definition: ut0mpmcbq.h:196
Pad m_pad1
Definition: ut0mpmcbq.h:199
mpmc_bq(size_t n_elems)
Constructor.
Definition: ut0mpmcbq.h:42
byte[ut::INNODB_CACHE_LINE_SIZE] Pad
Definition: ut0mpmcbq.h:185
Cell *const m_ring
Definition: ut0mpmcbq.h:197
std::atomic< size_t > m_enqueue_pos
Definition: ut0mpmcbq.h:200
~mpmc_bq()
Destructor.
Definition: ut0mpmcbq.h:58
mpmc_bq & operator=(mpmc_bq &&)=delete
mpmc_bq(mpmc_bq &&)=delete
static Bigint * diff(Bigint *a, Bigint *b, Stack_alloc *alloc)
Definition: dtoa.cc:1082
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:48
constexpr size_t INNODB_CACHE_LINE_SIZE
CPU cache line size.
Definition: ut0cpu_cache.h:41
T * new_arr_withkey(PSI_memory_key_t key, Args &&... args)
Dynamically allocates storage for an array of T's.
Definition: ut0new.h:874
void delete_arr(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new_arr*() variants.
Definition: ut0new.h:1109
required string type
Definition: replication_group_member_actions.proto:34
Definition: ut0mpmcbq.h:187
T m_data
Definition: ut0mpmcbq.h:189
std::atomic< size_t > m_pos
Definition: ut0mpmcbq.h:188
Utilities related to CPU cache.
#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