This class provides a thread safe implementation of a queue. It uses boost::circular_buffer<T> as an internal queue data structure. Along with that it makes use of the C++ standard threading library to protect the queue and provide synchronization among multiple threads.  
 More...
#include <ringbuffer.hpp>
|  | 
|  | RingBuffer () | 
|  | Constructor of the RingBuffer class. 
 | 
|  | 
| RingBuffer & | operator= (const RingBuffer &)=delete | 
|  | Copy assignment. 
 | 
|  | 
|  | RingBuffer (RingBuffer const &other) | 
|  | Copy constructor of the RingBuffer class. This enables an instance of this class to be passed around as value. 
 | 
|  | 
| int | size () const | 
|  | 
| void | push (const T &value) | 
|  | Pushes a value to the queue. 
 | 
|  | 
| void | pushData (T &value, int threshold) | 
|  | 
| bool | empty () const | 
|  | Checks if the queue is empty. 
 | 
|  | 
| bool | tryAndPop (T &value) | 
|  | Tries to pop a value from the queue and copy it to the value passed in as an argument. This is a non blocking call and returns immediately with a status of retrieval. 
 | 
|  | 
| std::shared_ptr< T > | tryAndPop () | 
|  | Tries to pop an item from the queue and returns a std::shared_ptr<T> This is a non blocking call and returns immediately with a status of retrieval. 
 | 
|  | 
| void | waitAndPop (T &value) | 
|  | Waits and pops an item from the queue and copies it to value passed in as an argument This is a blocking call and it waits until an item is available to be popped. 
 | 
|  | 
| std::shared_ptr< T > | waitAndPop () | 
|  | Waits and pops an item from the queue and returns a shared_ptr<T> This is a blocking call and it waits until an item is available to be popped. 
 | 
|  | 
| T | waitAndPopValue () | 
|  | Waits and pops an item from the queue and returns a copy of the item This is a blocking call and it waits until an item is available to be popped. 
 | 
|  | 
| bool | waitForAndPop (T &value, std::chrono::milliseconds waitDuration) | 
|  | Waits and pops an item from the queue and copies it to value passed in as an argument. This is a blocking call with a timeout functionality. 
 | 
|  | 
| std::shared_ptr< T > | waitForAndPop (std::chrono::milliseconds waitDuration) | 
|  | Waits and pops an item from the queue and returns a std::shared_ptr<T>. This is a blocking call with a timeout functionality. 
 | 
|  | 
template<typename T>
class iceflow::RingBuffer< T >
This class provides a thread safe implementation of a queue. It uses boost::circular_buffer<T> as an internal queue data structure. Along with that it makes use of the C++ standard threading library to protect the queue and provide synchronization among multiple threads. 
◆ RingBuffer()
Copy constructor of the RingBuffer class. This enables an instance of this class to be passed around as value. 
- Parameters
- 
  
    | other | The instance to be copied from |  
 
 
 
◆ empty()
Checks if the queue is empty. 
- Returns
- true if the queue is empty, else false 
 
 
◆ push()
Pushes a value to the queue. 
- Parameters
- 
  
    | value | The item to be pushed to the queue |  
 
 
 
◆ tryAndPop() [1/2]
Tries to pop an item from the queue and returns a std::shared_ptr<T> This is a non blocking call and returns immediately with a status of retrieval. 
- Returns
- nullptr if there is no item to be popped, else returns a shared_ptr pointing to the popped item. 
 
 
◆ tryAndPop() [2/2]
Tries to pop a value from the queue and copy it to the value passed in as an argument. This is a non blocking call and returns immediately with a status of retrieval. 
- Parameters
- 
  
    | value | An instance to which the popped item is to be copied to. |  
 
- Returns
- true if there exists an item to be popped, else false. 
 
 
◆ waitAndPop() [1/2]
Waits and pops an item from the queue and returns a shared_ptr<T> This is a blocking call and it waits until an item is available to be popped. 
- Returns
- returns a std::shared_ptr<T> pointing to an instance of the popped item 
 
 
◆ waitAndPop() [2/2]
Waits and pops an item from the queue and copies it to value passed in as an argument This is a blocking call and it waits until an item is available to be popped. 
- Parameters
- 
  
    | value | An instance to which the popped item is to be copied to. |  
 
 
 
◆ waitAndPopValue()
Waits and pops an item from the queue and returns a copy of the item This is a blocking call and it waits until an item is available to be popped. 
- Returns
- returns a copy of the instance of the popped item. 
 
 
◆ waitForAndPop() [1/2]
template<typename T > 
  
  | 
        
          | std::shared_ptr< T > iceflow::RingBuffer< T >::waitForAndPop | ( | std::chrono::milliseconds | waitDuration | ) |  |  | inline | 
 
Waits and pops an item from the queue and returns a std::shared_ptr<T>. This is a blocking call with a timeout functionality. 
- Parameters
- 
  
    | waitDuration | Wait for at most waitDuration |  
 
- Returns
- returns nullptr if it timed out, else returns a std::shared_ptr<T> pointing to an instance of item popped. 
 
 
◆ waitForAndPop() [2/2]
template<typename T > 
  
  | 
        
          | bool iceflow::RingBuffer< T >::waitForAndPop | ( | T & | value, |  
          |  |  | std::chrono::milliseconds | waitDuration ) |  | inline | 
 
Waits and pops an item from the queue and copies it to value passed in as an argument. This is a blocking call with a timeout functionality. 
- Parameters
- 
  
    | value | An instance to which the popped item is to be copied to. |  | waitDuration | Wait for at most waitDuration. |  
 
- Returns
- returns false if the wait timedout, returns true if an item was popped and copied. 
 
 
The documentation for this class was generated from the following file: