2 #ifndef SST_CORE_INTERPROCESS_CIRCULARBUFFER_H
3 #define SST_CORE_INTERPROCESS_CIRCULARBUFFER_H
9 namespace Interprocess {
21 void setBufferSize(
const size_t bufferSize)
23 if ( buffSize != 0 ) {
24 fprintf(stderr,
"Already specified size for buffer\n");
28 buffSize = bufferSize;
38 if( readIndex != writeIndex ) {
39 const T result = buffer[readIndex];
40 readIndex = (readIndex + 1) % buffSize;
47 bufferMutex.processorPause(loop_counter++);
51 bool readNB(T* result) {
52 if( bufferMutex.try_lock() ) {
53 if( readIndex != writeIndex ) {
54 *result = buffer[readIndex];
55 readIndex = (readIndex + 1) % buffSize;
67 void write(
const T& v) {
73 if( ((writeIndex + 1) % buffSize) != readIndex ) {
74 buffer[writeIndex] = v;
75 writeIndex = (writeIndex + 1) % buffSize;
83 bufferMutex.processorPause(loop_counter++);
93 readIndex = writeIndex;
Definition: circularBuffer.h:12
Definition: sstmutex.h:16