MySQL 9.1.0
Source Code Documentation
mpmc_bq< T > Class Template Reference

Multiple producer consumer, bounded queue Implementation of Dmitry Vyukov's MPMC algorithm http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue. More...

#include <ut0mpmcbq.h>

Classes

struct  Cell
 

Public Member Functions

 mpmc_bq (size_t n_elems)
 Constructor. More...
 
 ~mpmc_bq ()
 Destructor. More...
 
bool enqueue (T const &data)
 Enqueue an element. More...
 
bool dequeue (T &data)
 Dequeue an element. More...
 
size_t capacity () const
 
bool empty () const
 

Private Types

using Pad = byte[ut::INNODB_CACHE_LINE_SIZE]
 
using Aligned = typename std::aligned_storage< sizeof(Cell), std::alignment_of< Cell >::value >::type
 

Private Member Functions

 mpmc_bq (mpmc_bq &&)=delete
 
 mpmc_bq (const mpmc_bq &)=delete
 
mpmc_bqoperator= (mpmc_bq &&)=delete
 
mpmc_bqoperator= (const mpmc_bq &)=delete
 

Private Attributes

Pad m_pad0
 
Cell *const m_ring
 
size_t const m_capacity
 
Pad m_pad1
 
std::atomic< size_t > m_enqueue_pos
 
Pad m_pad2
 
std::atomic< size_t > m_dequeue_pos
 
Pad m_pad3
 

Detailed Description

template<typename T>
class mpmc_bq< T >

Multiple producer consumer, bounded queue Implementation of Dmitry Vyukov's MPMC algorithm http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue.

Member Typedef Documentation

◆ Aligned

template<typename T >
using mpmc_bq< T >::Aligned = typename std::aligned_storage<sizeof(Cell), std::alignment_of<Cell>::value>::type
private

◆ Pad

template<typename T >
using mpmc_bq< T >::Pad = byte[ut::INNODB_CACHE_LINE_SIZE]
private

Constructor & Destructor Documentation

◆ mpmc_bq() [1/3]

template<typename T >
mpmc_bq< T >::mpmc_bq ( size_t  n_elems)
inlineexplicit

Constructor.

Parameters
[in]n_elemsMax number of elements allowed

◆ ~mpmc_bq()

template<typename T >
mpmc_bq< T >::~mpmc_bq ( )
inline

Destructor.

◆ mpmc_bq() [2/3]

template<typename T >
mpmc_bq< T >::mpmc_bq ( mpmc_bq< T > &&  )
privatedelete

◆ mpmc_bq() [3/3]

template<typename T >
mpmc_bq< T >::mpmc_bq ( const mpmc_bq< T > &  )
privatedelete

Member Function Documentation

◆ capacity()

template<typename T >
size_t mpmc_bq< T >::capacity ( ) const
inline
Returns
the capacity of the queue

◆ dequeue()

template<typename T >
bool mpmc_bq< T >::dequeue ( T &  data)
inline

Dequeue an element.

Parameters
[out]dataElement read from the queue
Returns
true on success

◆ empty()

template<typename T >
bool mpmc_bq< T >::empty ( ) const
inline
Returns
true if the queue is empty.

◆ enqueue()

template<typename T >
bool mpmc_bq< T >::enqueue ( T const &  data)
inline

Enqueue an element.

Parameters
[in]dataElement to insert, it will be copied
Returns
true on success

◆ operator=() [1/2]

template<typename T >
mpmc_bq & mpmc_bq< T >::operator= ( const mpmc_bq< T > &  )
privatedelete

◆ operator=() [2/2]

template<typename T >
mpmc_bq & mpmc_bq< T >::operator= ( mpmc_bq< T > &&  )
privatedelete

Member Data Documentation

◆ m_capacity

template<typename T >
size_t const mpmc_bq< T >::m_capacity
private

◆ m_dequeue_pos

template<typename T >
std::atomic<size_t> mpmc_bq< T >::m_dequeue_pos
private

◆ m_enqueue_pos

template<typename T >
std::atomic<size_t> mpmc_bq< T >::m_enqueue_pos
private

◆ m_pad0

template<typename T >
Pad mpmc_bq< T >::m_pad0
private

◆ m_pad1

template<typename T >
Pad mpmc_bq< T >::m_pad1
private

◆ m_pad2

template<typename T >
Pad mpmc_bq< T >::m_pad2
private

◆ m_pad3

template<typename T >
Pad mpmc_bq< T >::m_pad3
private

◆ m_ring

template<typename T >
Cell* const mpmc_bq< T >::m_ring
private

The documentation for this class was generated from the following file: