lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
MPSCQueue Class Reference

Ring buffer of uint32_t pointers. More...

#include <mpscqueue.hh>

Public Member Functions

 MPSCQueue (int capacity)
 Allocate a ring of capacity pointers; capacity is used through a mask, so it must be a power of 2.
 
void push (uint32_t *value)
 Claim the next slot, store value in it, wait until earlier pushes have been published, then publish it and wake the consumer if it was waiting on this slot.
 
uint32_t * pop ()
 Return the oldest element, blocking while the queue is empty.
 
bool is_empty ()
 Return true if all published elements have been popped.
 
 ~MPSCQueue ()
 Free the ring.
 

Detailed Description

Ring buffer of uint32_t pointers.

push() may be called from several threads; pop() from one thread only and blocks until an element is available (per the header comment). There is no check for a full queue.

Constructor & Destructor Documentation

◆ MPSCQueue()

MPSCQueue::MPSCQueue ( int  capacity)

Allocate a ring of capacity pointers; capacity is used through a mask, so it must be a power of 2.

◆ ~MPSCQueue()

MPSCQueue::~MPSCQueue ( )

Free the ring.

Member Function Documentation

◆ is_empty()

bool MPSCQueue::is_empty ( )

Return true if all published elements have been popped.

◆ pop()

uint32_t * MPSCQueue::pop ( )

Return the oldest element, blocking while the queue is empty.

◆ push()

void MPSCQueue::push ( uint32_t *  value)

Claim the next slot, store value in it, wait until earlier pushes have been published, then publish it and wake the consumer if it was waiting on this slot.


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