The Pedigree Project 0.1
Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
IntrusiveMpscQueue< Node, NextMember > Class Template Reference

#include <IntrusiveMpscQueue.h>

+ Inheritance diagram for IntrusiveMpscQueue< Node, NextMember >:
+ Collaboration diagram for IntrusiveMpscQueue< Node, NextMember >:

Public Types

enum class  PopResult { Item , Empty , Transient }
 

Public Member Functions

 IntrusiveMpscQueue (Node &stub)
 
void push (Node &node)
 
MUST_USE_RESULT PopResult pop (Node *&out)
 

Private Member Functions

 IntrusiveMpscQueue (const IntrusiveMpscQueue &)=delete
 
IntrusiveMpscQueueoperator= (const IntrusiveMpscQueue &)=delete
 
Node * beginPush (Node &node)
 
Node * loadHead () const
 

Static Private Member Functions

static void finishPush (Node &node, Node *previous)
 
static Node * loadNext (Node *node)
 
static void storeNext (Node *node, Node *next, int memoryOrder)
 

Private Attributes

Node * m_Head
 
Node * m_Tail
 
Node *const m_Stub
 

Friends

class IntrusiveMpscQueueTestAccess< Node, NextMember >
 

Detailed Description

template<typename Node, Node *Node::* NextMember>
class IntrusiveMpscQueue< Node, NextMember >

Allocation-free intrusive queue for any number of producers and one consumer.

Storage is bounded by the caller-owned nodes supplied to push(). The caller must reserve one node as the queue's permanent stub and keep every queued node alive. A node may not be published again until pop() returns it as an Item. The link member must be naturally pointer-aligned and belongs exclusively to the queue while its node is published.

Producers never wait: they atomically replace the head and then link their predecessor. The consumer also never waits. It reports Transient when a producer is between those two operations, allowing an IRQ drain loop to defer another attempt instead of spinning inside hard-interrupt context.

Definition at line 33 of file IntrusiveMpscQueue.h.

Member Enumeration Documentation

◆ PopResult

template<typename Node , Node *Node::* NextMember>
enum class IntrusiveMpscQueue::PopResult
strong

Definition at line 41 of file IntrusiveMpscQueue.h.

Constructor & Destructor Documentation

◆ IntrusiveMpscQueue()

template<typename Node , Node *Node::* NextMember>
IntrusiveMpscQueue< Node, NextMember >::IntrusiveMpscQueue ( Node &  stub)
inlineexplicit

Constructs an empty queue using the stub as permanent internal storage. The stub must outlive the queue and must never be passed to push().

Definition at line 51 of file IntrusiveMpscQueue.h.

Member Function Documentation

◆ beginPush()

template<typename Node , Node *Node::* NextMember>
Node * IntrusiveMpscQueue< Node, NextMember >::beginPush ( Node &  node)
inlineprivate

Definition at line 120 of file IntrusiveMpscQueue.h.

◆ finishPush()

template<typename Node , Node *Node::* NextMember>
static void IntrusiveMpscQueue< Node, NextMember >::finishPush ( Node &  node,
Node *  previous 
)
inlinestaticprivate

Definition at line 127 of file IntrusiveMpscQueue.h.

◆ loadHead()

template<typename Node , Node *Node::* NextMember>
Node * IntrusiveMpscQueue< Node, NextMember >::loadHead ( ) const
inlineprivate

Definition at line 132 of file IntrusiveMpscQueue.h.

◆ loadNext()

template<typename Node , Node *Node::* NextMember>
static Node * IntrusiveMpscQueue< Node, NextMember >::loadNext ( Node *  node)
inlinestaticprivate

Definition at line 136 of file IntrusiveMpscQueue.h.

◆ pop()

template<typename Node , Node *Node::* NextMember>
MUST_USE_RESULT PopResult IntrusiveMpscQueue< Node, NextMember >::pop ( Node *&  out)
inline

Attempts to remove one node without waiting.

Item makes out immediately safe for the consumer to reuse, destroy, or publish again. Empty is a point-in-time observation and can immediately become stale. Transient means an in-progress producer owns the missing predecessor link, so the consumer should retry later. Both non-Item results set out to nullptr.

Definition at line 70 of file IntrusiveMpscQueue.h.

References IntrusiveMpscQueue< Node, NextMember >::push().

◆ push()

template<typename Node , Node *Node::* NextMember>
void IntrusiveMpscQueue< Node, NextMember >::push ( Node &  node)
inline

Publishes one caller-owned node in constant time.

Definition at line 56 of file IntrusiveMpscQueue.h.

Referenced by IntrusiveMpscQueue< Node, NextMember >::pop().

+ Here is the caller graph for this function:

◆ storeNext()

template<typename Node , Node *Node::* NextMember>
static void IntrusiveMpscQueue< Node, NextMember >::storeNext ( Node *  node,
Node *  next,
int  memoryOrder 
)
inlinestaticprivate

Definition at line 140 of file IntrusiveMpscQueue.h.

Friends And Related Symbol Documentation

◆ IntrusiveMpscQueueTestAccess< Node, NextMember >

template<typename Node , Node *Node::* NextMember>
friend class IntrusiveMpscQueueTestAccess< Node, NextMember >
friend

Definition at line 70 of file IntrusiveMpscQueue.h.

Member Data Documentation

◆ m_Head

template<typename Node , Node *Node::* NextMember>
Node* IntrusiveMpscQueue< Node, NextMember >::m_Head
private

Definition at line 144 of file IntrusiveMpscQueue.h.

◆ m_Stub

template<typename Node , Node *Node::* NextMember>
Node* const IntrusiveMpscQueue< Node, NextMember >::m_Stub
private

Definition at line 146 of file IntrusiveMpscQueue.h.

◆ m_Tail

template<typename Node , Node *Node::* NextMember>
Node* IntrusiveMpscQueue< Node, NextMember >::m_Tail
private

Definition at line 145 of file IntrusiveMpscQueue.h.


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