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

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

template<class T, typename EqualsTo = std::equal_to<T>>
class nrt::BoundedSet< T, EqualsTo >

Thread-safe synchronized producer/consumer queue with element replacement policy.

BoundedSet is designed for use in producer/consumer scenarios where multiple threads wish to push and pop data onto/from the set asynchronously. Threads that try to pop data when the set is empty will sleep until data is actually available, and threads that try to push data when the set is full will block until some space is available in the set. Threads that try to push an element that is already in the set will see that element pushed or not according to the insert policy.

Definition at line 65 of file BoundedSet.H.

Public Member Functions

 BoundedSet (size_t const siz, EqualsTo const &eq=EqualsTo())
 Create a new BoundedSet with no data.
void push (T const &val, BoundedSetInsertPolicy const pol=BoundedSetInsertPolicy::Preserve)
 Push a new data element into the set, potentially sleeping if set is full.
pop ()
 Pop oldest data element off of the set, potentially sleeping until one is available.
size_t const filled_size ()
 Current number of items actually in the set.
size_t const size () const
 Max size of the set.

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