Jamoma API  0.6.0.a19
TTFifo< T > Class Template Reference

First-in/First-out buffer that is non-blocking and thread-safe for writing from a single thread and reading from another (possibly different) single thread. More...

#include <TTFifo.h>

Public Member Functions

void resize (TTUInt32 &newSlotCount)
 Change the number of slots in the circular queue. More...
 
TTFifoWriteStatus push (const T &item)
 Copy an item into the queue. More...
 
TTFifoReadStatus pop (T &item)
 Copy the next item and pop it from the queue. More...
 

Protected Attributes

TTAtomicUInt mUpdateCounter
 UC – only modified by the producer.
 
TTAtomicUInt mAcknowledgementCounter
 AC – only modified by the consumer.
 
TTUInt32 mSlotCount
 count of slots in mBuffer – should be power of 2, will use as a bitmask
 
TTUInt32 mDoubleSlotCount
 2 * mBufferSize, cached for performance
 

Detailed Description

template<class T>
class TTFifo< T >

First-in/First-out buffer that is non-blocking and thread-safe for writing from a single thread and reading from another (possibly different) single thread.

TTQueue

Definition at line 23 of file TTFifo.h.

Member Function Documentation

template<class T >
TTFifoReadStatus TTFifo< T >::pop ( T &  item)
inline

Copy the next item and pop it from the queue.

Definition at line 115 of file TTFifo.h.

References TTFifo< T >::mAcknowledgementCounter, TTFifo< T >::mSlotCount, and TTFifo< T >::mUpdateCounter.

template<class T >
TTFifoWriteStatus TTFifo< T >::push ( const T &  item)
inline
template<class T >
void TTFifo< T >::resize ( TTUInt32 newSlotCount)
inline

Change the number of slots in the circular queue.

This method should be used with extreme caution as it is not thread-safe with regards to the push() and pop() methods.

Parameters
newSlotCountMust be a power of two. If the argument provided is not a power-of-two, it will be increased to the next-higher power of two upon return.

Definition at line 59 of file TTFifo.h.


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