iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::BoundedBuffer< T > Class Template Reference

#include <nrt/Core/Design/BoundedBuffer.H>

template<class T>
class nrt::BoundedBuffer< T >

Thread-safe synchronized producer/consumer queue.

BoundedBuffer is designed for use in producer/consumer scenarios where multiple threads wish to push and pop data onto/from the buffer asynchronously. Threads that try to pop data when the buffer is empty will sleep until data is actually available, and threads that try to push data when the buffer is full will block until some space is available in the buffer.

Definition at line 52 of file BoundedBuffer.H.

Public Member Functions

 BoundedBuffer (size_t const siz)
 Create a new BoundedBuffer with no data.
 
void push (T const &val)
 Push a new data element into the buffer, potentially sleeping if buffer is full.
 
pop ()
 Pop oldest data element off of the buffer, potentially sleeping until one is available.
 
size_t const filled_size ()
 Current number of items actually in the buffer.
 
size_t const size () const
 Max size of the buffer.
 

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