12#ifndef SST_CORE_INTERPROCESS_CIRCULARBUFFER_H
13#define SST_CORE_INTERPROCESS_CIRCULARBUFFER_H
19namespace Interprocess {
33 bool setBufferSize(
const size_t bufferSize)
35 if ( buffSize != 0 ) {
36 fprintf(stderr,
"Already specified size for buffer\n");
40 buffSize = bufferSize;
52 if ( readIndex != writeIndex ) {
53 const T result = buffer[readIndex];
54 readIndex = (readIndex + 1) % buffSize;
61 bufferMutex.processorPause(loop_counter++);
65 bool readNB(T* result)
67 if ( bufferMutex.try_lock() ) {
68 if ( readIndex != writeIndex ) {
69 *result = buffer[readIndex];
70 readIndex = (readIndex + 1) % buffSize;
82 void write(
const T& v)
89 if ( ((writeIndex + 1) % buffSize) != readIndex ) {
90 buffer[writeIndex] = v;
91 writeIndex = (writeIndex + 1) % buffSize;
99 bufferMutex.processorPause(loop_counter++);
108 readIndex = writeIndex;
109 __sync_synchronize();
110 bufferMutex.unlock();
Definition: circularBuffer.h:23
Definition: sstmutex.h:26