MySQL 8.0.32
Source Code Documentation
mysql_harness::MPMCQueueMS2Lock< T > Class Template Reference

a unbounded multi-producer multi-consumer queue. More...

#include <mpmc_queue.h>

Classes

struct  Node
 

Public Types

using value_type = T
 

Public Member Functions

 MPMCQueueMS2Lock ()
 
 ~MPMCQueueMS2Lock ()
 
bool enqueue (const T &item)
 enqueue an element. More...
 
bool enqueue (T &&item)
 enqueue an element. More...
 
bool dequeue (T &item)
 try to dequeue element. More...
 

Private Attributes

std::mutex head_mutex_
 
std::mutex tail_mutex_
 
Nodehead_
 
Nodetail_
 

Detailed Description

template<typename T>
class mysql_harness::MPMCQueueMS2Lock< T >

a unbounded multi-producer multi-consumer queue.

multiple threads can read and write at the same time into the queue

  • enqueue and dequeue do not block each other

see:

  • Micheal & Scott: two-lock concurrent queue
  • "An Unbounded Total Queue" in "The Art of MultiProcessor Programming"

Member Typedef Documentation

◆ value_type

template<typename T >
using mysql_harness::MPMCQueueMS2Lock< T >::value_type = T

Constructor & Destructor Documentation

◆ MPMCQueueMS2Lock()

template<typename T >
mysql_harness::MPMCQueueMS2Lock< T >::MPMCQueueMS2Lock ( )
inline

◆ ~MPMCQueueMS2Lock()

template<typename T >
mysql_harness::MPMCQueueMS2Lock< T >::~MPMCQueueMS2Lock ( )
inline

Member Function Documentation

◆ dequeue()

template<typename T >
bool mysql_harness::MPMCQueueMS2Lock< T >::dequeue ( T &  item)
inline

try to dequeue element.

Parameters
itemlocation of dequeued item if dequeue() was successful
Returns
if item was written
Return values
truefirst item removed from the queue and assigned to item
falsequeue is empty

◆ enqueue() [1/2]

template<typename T >
bool mysql_harness::MPMCQueueMS2Lock< T >::enqueue ( const T &  item)
inline

enqueue an element.

Parameters
itemitem to enqueue
Returns
if item was enqueued
Return values
trueitem got assigned to queue

◆ enqueue() [2/2]

template<typename T >
bool mysql_harness::MPMCQueueMS2Lock< T >::enqueue ( T &&  item)
inline

enqueue an element.

Parameters
itemitem to enqueue
Returns
if item was enqueued
Return values
trueitem got assigned to queue

Member Data Documentation

◆ head_

template<typename T >
Node* mysql_harness::MPMCQueueMS2Lock< T >::head_
private

◆ head_mutex_

template<typename T >
std::mutex mysql_harness::MPMCQueueMS2Lock< T >::head_mutex_
private

◆ tail_

template<typename T >
Node* mysql_harness::MPMCQueueMS2Lock< T >::tail_
private

◆ tail_mutex_

template<typename T >
std::mutex mysql_harness::MPMCQueueMS2Lock< T >::tail_mutex_
private

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