50 explicit RingBuffer(
const std::string& name,
unsigned int nwords = 0);
59 int insq(
const int* buf,
int size,
bool checkTx =
false);
63 int spyq(
int* buf)
const;
Class to manage a Ring Buffer placed in an IPC shared memory.
void dump_db()
Print some info on the RingBufInfo structure.
int insq(const int *buf, int size, bool checkTx=false)
Append a buffer to the RingBuffer.
int m_shmsize
Size of shared memory segment, in bytes.
struct RingBufInfo * m_bufinfo
structure to manage ring buffer.
int tryClear()
Clear the RingBuffer, if the semaphore isn't locked at the moment.
bool m_file
True if m_pathfd needs to be closed.
int remq_counter() const
Return number of remq() calls.
int clear()
Clear the RingBuffer.
void txAttached()
Increase the number of attached Tx counter.
int spyq(int *buf) const
Prefetch a buffer from the RingBuffer w/o removing it.
void cleanup()
Function to detach and remove shared memory.
int m_remq_counter
count remq() calls.
void txDetached()
Decrease the number of attached Tx counter.
key_t m_shmkey
SHM key, see shmget(2).
int shmid() const
Return ID of the shared memory.
void dumpInfo() const
Dump contents of RingBufInfo metadata.
static const int c_DefaultSize
Standard size of buffer, in integers (~60MB).
int numq() const
Returns number of entries/buffers in the RingBuffer.
int m_shmid
ID of shared memory segment.
bool allRxWaiting() const
True if and only if buffer is empty and nbusy == 0.
void kill()
Cause termination of reading processes (if they use isDead()).
int remq(int *buf)
Pick up a buffer from the RingBuffer.
int m_pathfd
Associated file descriptor.
int insq_counter() const
Return number of insq() calls.
std::string m_pathname
Path for identifying shared memory if named ring buffer is created.
void openSHM(int nwords)
open shared memory
bool isDead() const
If True, the ring buffer is empty and has no attached Tx modules (i.e.
bool m_procIsBusy
Is this process currently processing events from this RingBuffer?
int * m_buftop
Points to memory after the end of m_bufinfo.
int m_insq_counter
count insq() calls.
std::string m_semshmFileName
file path containing ids of shm and sema for private shared mem, used for easier cleanup if we fail t...
bool m_new
True if we created the ring buffer ourselves (and need to clean it).
int ninsq() const
Return number of insq() calls for current buffer.
void forceClear()
Forcefully clear the RingBuffer with resetting semaphore.
key_t m_semkey
Semaphore key, see semget(2).
int nremq() const
Return number of remq() calls for current buffer.
int * m_shmadr
Address of attached shared memory segment.
Abstract base class for different kinds of events.
Internal metadata structure for RingBuffer.
int numAttachedTx
number of attached sending processes.
int errtype
Error state? 0: Normal, 1: buffer full and wptr>rptr, others are complicated.
int wptr
Pointer for writing entries.
int size
ring buffer size (integers), minus this header.
int nattached
Number of RingBuffer instances currently attached to this buffer.
int nbusy
Number of attached reading processes currently processing events.
int nremq
Count remq() calls for this buffer.
int nbuf
Number of entries in ring buffer.
int rptr
Pointer for reading entries.
int remain
Unsure, always equal to size.
int prevwptr
Previous state of wptr (for error recovery).
int ninsq
Count insq() calls for this buffer.