TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MPSCQueue< T > Class Template Reference

#include <MPSCQueue.h>

Classes

struct  Node
 

Public Member Functions

 MPSCQueue ()
 
 ~MPSCQueue ()
 
void Enqueue (T *input)
 
bool Dequeue (T *&result)
 

Private Member Functions

 MPSCQueue (MPSCQueue const &)=delete
 
MPSCQueueoperator= (MPSCQueue const &)=delete
 

Private Attributes

std::atomic< Node * > _head
 
std::atomic< Node * > _tail
 

Constructor & Destructor Documentation

template<typename T>
MPSCQueue< T >::MPSCQueue ( )
inline
30  : _head(new Node()), _tail(_head.load(std::memory_order_relaxed))
31  {
32  Node* front = _head.load(std::memory_order_relaxed);
33  front->Next.store(nullptr, std::memory_order_relaxed);
34  }
std::atomic< Node * > _tail
Definition: MPSCQueue.h:77
std::atomic< Node * > _head
Definition: MPSCQueue.h:76
template<typename T>
MPSCQueue< T >::~MPSCQueue ( )
inline
37  {
38  T* output;
39  while (this->Dequeue(output))
40  ;
41 
42  Node* front = _head.load(std::memory_order_relaxed);
43  delete front;
44  }
bool Dequeue(T *&result)
Definition: MPSCQueue.h:53
#define output
Definition: wire_format_lite.h:381
std::atomic< Node * > _head
Definition: MPSCQueue.h:76
template<typename T>
MPSCQueue< T >::MPSCQueue ( MPSCQueue< T > const )
privatedelete

Member Function Documentation

template<typename T>
bool MPSCQueue< T >::Dequeue ( T *&  result)
inline
54  {
55  Node* tail = _tail.load(std::memory_order_relaxed);
56  Node* next = tail->Next.load(std::memory_order_acquire);
57  if (!next)
58  return false;
59 
60  result = next->Data;
61  _tail.store(next, std::memory_order_release);
62  delete tail;
63  return true;
64  }
int next(int i, int n)
Definition: RecastContour.cpp:469
std::atomic< Node * > _tail
Definition: MPSCQueue.h:77

+ Here is the caller graph for this function:

template<typename T>
void MPSCQueue< T >::Enqueue ( T *  input)
inline
47  {
48  Node* node = new Node(input);
49  Node* prevHead = _head.exchange(node, std::memory_order_acq_rel);
50  prevHead->Next.store(node, std::memory_order_release);
51  }
std::atomic< Node * > _head
Definition: MPSCQueue.h:76
#define input
Definition: wire_format_lite.h:242

+ Here is the caller graph for this function:

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

Member Data Documentation

template<typename T>
std::atomic<Node*> MPSCQueue< T >::_head
private
template<typename T>
std::atomic<Node*> MPSCQueue< T >::_tail
private

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