|
The Pedigree Project 0.1
|
#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 | |
| IntrusiveMpscQueue & | operator= (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 > |
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.
|
strong |
Definition at line 41 of file IntrusiveMpscQueue.h.
|
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.
|
inlineprivate |
Definition at line 120 of file IntrusiveMpscQueue.h.
|
inlinestaticprivate |
Definition at line 127 of file IntrusiveMpscQueue.h.
|
inlineprivate |
Definition at line 132 of file IntrusiveMpscQueue.h.
|
inlinestaticprivate |
Definition at line 136 of file IntrusiveMpscQueue.h.
|
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().
|
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:
|
inlinestaticprivate |
Definition at line 140 of file IntrusiveMpscQueue.h.
|
friend |
Definition at line 70 of file IntrusiveMpscQueue.h.
|
private |
Definition at line 144 of file IntrusiveMpscQueue.h.
|
private |
Definition at line 146 of file IntrusiveMpscQueue.h.
|
private |
Definition at line 145 of file IntrusiveMpscQueue.h.