MySQL 8.0.39
Source Code Documentation
Gcs_mpsc_queue< T, Deleter > Class Template Reference

MPSC queue with FIFO semantics. More...

#include <gcs_mpsc_queue.h>

Classes

class  Gcs_mpsc_queue_node
 Node that holds an element (payload) of the MPSC queue. More...
 

Public Member Functions

 Gcs_mpsc_queue ()
 Create an empty queue. More...
 
 Gcs_mpsc_queue (Deleter custom_deleter)
 
 ~Gcs_mpsc_queue ()
 Destroy the queued nodes. More...
 
 Gcs_mpsc_queue (Gcs_mpsc_queue const &)=delete
 
 Gcs_mpsc_queue (Gcs_mpsc_queue &&)=delete
 
Gcs_mpsc_queueoperator= (Gcs_mpsc_queue const &)=delete
 
Gcs_mpsc_queueoperator= (Gcs_mpsc_queue &&)=delete
 
bool push (T *payload)
 Insert payload at the end of the queue. More...
 
T * pop ()
 Attempt to retrieve the first element from the queue. More...
 

Private Attributes

Deleter m_payload_deleter
 
Gcs_mpsc_queue_nodem_tail
 
std::atomic< Gcs_mpsc_queue_node * > m_head
 

Detailed Description

template<typename T, typename Deleter = std::default_delete<T>>
class Gcs_mpsc_queue< T, Deleter >

MPSC queue with FIFO semantics.

Implemented as a linked list of nodes. Inspired by Dmitry Vyukov's "non-intrusive MPSC node-based queue" algorithm, available on 2017-07-10 at http://www.1024cores.net/home/lock-free-algorithms/queues/non-intrusive-mpsc-node-based-queue

Constructor & Destructor Documentation

◆ Gcs_mpsc_queue() [1/4]

template<typename T , typename Deleter = std::default_delete<T>>
Gcs_mpsc_queue< T, Deleter >::Gcs_mpsc_queue ( )
inline

Create an empty queue.

◆ Gcs_mpsc_queue() [2/4]

template<typename T , typename Deleter = std::default_delete<T>>
Gcs_mpsc_queue< T, Deleter >::Gcs_mpsc_queue ( Deleter  custom_deleter)
inline

◆ ~Gcs_mpsc_queue()

template<typename T , typename Deleter = std::default_delete<T>>
Gcs_mpsc_queue< T, Deleter >::~Gcs_mpsc_queue ( )
inline

Destroy the queued nodes.

◆ Gcs_mpsc_queue() [3/4]

template<typename T , typename Deleter = std::default_delete<T>>
Gcs_mpsc_queue< T, Deleter >::Gcs_mpsc_queue ( Gcs_mpsc_queue< T, Deleter > const &  )
delete

◆ Gcs_mpsc_queue() [4/4]

template<typename T , typename Deleter = std::default_delete<T>>
Gcs_mpsc_queue< T, Deleter >::Gcs_mpsc_queue ( Gcs_mpsc_queue< T, Deleter > &&  )
delete

Member Function Documentation

◆ operator=() [1/2]

template<typename T , typename Deleter = std::default_delete<T>>
Gcs_mpsc_queue & Gcs_mpsc_queue< T, Deleter >::operator= ( Gcs_mpsc_queue< T, Deleter > &&  )
delete

◆ operator=() [2/2]

template<typename T , typename Deleter = std::default_delete<T>>
Gcs_mpsc_queue & Gcs_mpsc_queue< T, Deleter >::operator= ( Gcs_mpsc_queue< T, Deleter > const &  )
delete

◆ pop()

template<typename T , typename Deleter = std::default_delete<T>>
T * Gcs_mpsc_queue< T, Deleter >::pop ( )
inline

Attempt to retrieve the first element from the queue.

Note that this is a non-blocking method.

Return values
T*if the queue is not empty
nullptrif the queue is empty

◆ push()

template<typename T , typename Deleter = std::default_delete<T>>
bool Gcs_mpsc_queue< T, Deleter >::push ( T *  payload)
inline

Insert payload at the end of the queue.

Parameters
payloadthe element to insert
Returns
true if the insertion was successful, false otherwise

Member Data Documentation

◆ m_head

template<typename T , typename Deleter = std::default_delete<T>>
std::atomic<Gcs_mpsc_queue_node *> Gcs_mpsc_queue< T, Deleter >::m_head
private

◆ m_payload_deleter

template<typename T , typename Deleter = std::default_delete<T>>
Deleter Gcs_mpsc_queue< T, Deleter >::m_payload_deleter
private

◆ m_tail

template<typename T , typename Deleter = std::default_delete<T>>
Gcs_mpsc_queue_node* Gcs_mpsc_queue< T, Deleter >::m_tail
private

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