Logo Search packages:      
Sourcecode: jacktrip version File versions  Download package

Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

RingBuffer Class Reference

Provides a ring-buffer (or circular-buffer) that can be written to and read from asynchronously (blocking) or synchronously (non-blocking). More...

#include <RingBuffer.h>

Inheritance diagram for RingBuffer:
Inheritance graph
[legend]

List of all members.

Public Member Functions

void insertSlotBlocking (const int8_t *ptrToSlot)
 Insert a slot into the RingBuffer from ptrToSlot. This method will block until there's space in the buffer.
void insertSlotNonBlocking (const int8_t *ptrToSlot)
 Same as insertSlotBlocking but non-blocking (asynchronous)
void readSlotBlocking (int8_t *ptrToReadSlot)
 Read a slot from the RingBuffer into ptrToReadSlot. This method will block until there's space in the buffer.
void readSlotNonBlocking (int8_t *ptrToReadSlot)
 Same as readSlotBlocking but non-blocking (asynchronous)
 RingBuffer (int SlotSize, int NumSlots)
 The class constructor.
virtual ~RingBuffer ()
 The class destructor.

Protected Member Functions

virtual void setMemoryInReadSlotWithLastReadSlot (int8_t *ptrToReadSlot)
 Uses the last read slot to set the memory in the Read Slot.
virtual void setUnderrunReadSlot (int8_t *ptrToReadSlot)
 Sets the memory in the Read Slot when uderrun occurs. By default, this sets it to 0. Override this method in a subclass for a different behavior.

Private Member Functions

void debugDump () const
 Helper method to debug, prints member variables to terminal.
void overflowReset ()
 Resets the ring buffer for writes over-flows non-blocking.
void underrunReset ()
 Resets the ring buffer for reads under-runs non-blocking.

Private Attributes

QWaitCondition mBufferIsNotEmpty
 Buffer not empty condition to monitor threads.
QWaitCondition mBufferIsNotFull
 Buffer not full condition to monitor threads.
int mFullSlots
 Number of used (full) slots, in slot-size.
int8_t * mLastReadSlot
 Last slot read.
QMutex mMutex
 Mutex to protect read and write operations.
const int mNumSlots
 Number of Slots.
int mReadPosition
 Read Positions in the RingBuffer (Tail)
int8_t * mRingBuffer
 8-bit array of data (1-byte)
const int mSlotSize
 The size of one slot in byes.
const int mTotalSize
 Total size of the mRingBuffer = mSlotSize*mNumSlotss.
int mWritePosition
 Write Position in the RingBuffer (Head)

Detailed Description

Provides a ring-buffer (or circular-buffer) that can be written to and read from asynchronously (blocking) or synchronously (non-blocking).

The RingBuffer is an array of NumSlots slots of memory each of which is of size SlotSize bytes (8-bits). Slots can be read and written asynchronously/synchronously by multiple threads.

Definition at line 55 of file RingBuffer.h.


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

Generated by  Doxygen 1.6.0   Back to index