46 ut_a((n_elems >= 2) && ((n_elems & (n_elems - 1)) == 0));
48 for (
size_t i = 0; i < n_elems; ++i) {
49 m_ring[i].
m_pos.store(i, std::memory_order_relaxed);
62 [[nodiscard]]
bool enqueue(T
const &data) {
78 seq = cell->
m_pos.load(std::memory_order_acquire);
80 intptr_t
diff = (intptr_t)seq - (intptr_t)pos;
91 std::memory_order_relaxed)) {
95 }
else if (
diff < 0) {
109 cell->
m_pos.store(pos + 1, std::memory_order_release);
124 size_t seq = cell->
m_pos.load(std::memory_order_acquire);
126 auto diff = (intptr_t)seq - (intptr_t)(pos + 1);
135 std::memory_order_relaxed)) {
139 }
else if (
diff < 0) {
169 size_t seq = cell->
m_pos.load(std::memory_order_acquire);
171 auto diff = (intptr_t)seq - (intptr_t)(pos + 1);
175 }
else if (
diff < 0) {
192 typename std::aligned_storage<
sizeof(
Cell),
193 std::alignment_of<Cell>::value>::
type;
Multiple producer consumer, bounded queue Implementation of Dmitry Vyukov's MPMC algorithm http://www...
Definition: ut0mpmcbq.h:37
Pad m_pad3
Definition: ut0mpmcbq.h:202
size_t const m_capacity
Definition: ut0mpmcbq.h:197
mpmc_bq(const mpmc_bq &)=delete
std::atomic< size_t > m_dequeue_pos
Definition: ut0mpmcbq.h:201
bool empty() const
Definition: ut0mpmcbq.h:163
Pad m_pad2
Definition: ut0mpmcbq.h:200
typename std::aligned_storage< sizeof(Cell), std::alignment_of< Cell >::value >::type Aligned
Definition: ut0mpmcbq.h:193
size_t capacity() const
Definition: ut0mpmcbq.h:160
bool dequeue(T &data)
Dequeue an element.
Definition: ut0mpmcbq.h:117
bool enqueue(T const &data)
Enqueue an element.
Definition: ut0mpmcbq.h:62
mpmc_bq & operator=(const mpmc_bq &)=delete
Pad m_pad0
Definition: ut0mpmcbq.h:195
Pad m_pad1
Definition: ut0mpmcbq.h:198
mpmc_bq(size_t n_elems)
Constructor.
Definition: ut0mpmcbq.h:41
byte[ut::INNODB_CACHE_LINE_SIZE] Pad
Definition: ut0mpmcbq.h:184
Cell *const m_ring
Definition: ut0mpmcbq.h:196
std::atomic< size_t > m_enqueue_pos
Definition: ut0mpmcbq.h:199
~mpmc_bq()
Destructor.
Definition: ut0mpmcbq.h:57
mpmc_bq & operator=(mpmc_bq &&)=delete
mpmc_bq(mpmc_bq &&)=delete
static Bigint * diff(Bigint *a, Bigint *b, Stack_alloc *alloc)
Definition: dtoa.cc:1076
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:47
constexpr size_t INNODB_CACHE_LINE_SIZE
CPU cache line size.
Definition: ut0cpu_cache.h:40
T * new_arr_withkey(PSI_memory_key_t key, Args &&... args)
Dynamically allocates storage for an array of T's.
Definition: ut0new.h:873
void delete_arr(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new_arr*() variants.
Definition: ut0new.h:1108
required string type
Definition: replication_group_member_actions.proto:33
Definition: ut0mpmcbq.h:186
T m_data
Definition: ut0mpmcbq.h:188
std::atomic< size_t > m_pos
Definition: ut0mpmcbq.h:187
Utilities related to CPU cache.
#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