Scope
SynchronizedQueue< T > Class Template Reference

#include <SyncQueues.h>

Public Member Functions

 SynchronizedQueue ()
 
size_t Size () const
 
void Clear ()
 
void Enqueue (const T &elem)
 
void Enqueue (T &&elem)
 
Dequeue ()
 
Dequeue (const std::chrono::milliseconds &timeout)
 

Protected Attributes

std::deque< T > queue
 
std::mutex mut
 
std::condition_variable not_empty
 

Private Member Functions

 SynchronizedQueue (SynchronizedQueue< T > &)
 
SynchronizedQueue< T > operator= (SynchronizedQueue< T > &)
 

Detailed Description

template<class T>
class SynchronizedQueue< T >

A synchronized, thread-safe queue was modeled after ringbuffer example from boost?! and/or a Herb Sutter column?!

Definition at line 7 of file DaqController.h.

Constructor & Destructor Documentation

template<class T>
SynchronizedQueue< T >::SynchronizedQueue ( SynchronizedQueue< T > &  )
private

disable copy

template<class T>
SynchronizedQueue< T >::SynchronizedQueue ( )
inline

We need a default constructor here.

Definition at line 27 of file SyncQueues.h.

Member Function Documentation

template<class T>
SynchronizedQueue<T> SynchronizedQueue< T >::operator= ( SynchronizedQueue< T > &  )
private

disable assignment

template<class T>
size_t SynchronizedQueue< T >::Size ( ) const
inline
Returns
current queue size

Definition at line 31 of file SyncQueues.h.

template<class T>
void SynchronizedQueue< T >::Clear ( void  )
inline

Clears the queue.

Definition at line 37 of file SyncQueues.h.

template<class T>
void SynchronizedQueue< T >::Enqueue ( const T &  elem)
inline

Enqueues an element and notifies one waiting operation that queue is not empty.

Definition at line 43 of file SyncQueues.h.

template<class T>
void SynchronizedQueue< T >::Enqueue ( T &&  elem)
inline

Enqueues an element by moving and notifies one waiting operation that queue is not empty.

Definition at line 52 of file SyncQueues.h.

template<class T>
T SynchronizedQueue< T >::Dequeue ( )
inline

Dequeues front element, waits indefinitely if queue is empty.

Definition at line 61 of file SyncQueues.h.

template<class T>
T SynchronizedQueue< T >::Dequeue ( const std::chrono::milliseconds &  timeout)
inline

Dequeues front element, waits timeout if queue is empty.

Definition at line 71 of file SyncQueues.h.

Member Data Documentation

template<class T>
std::deque<T> SynchronizedQueue< T >::queue
protected

STL dequeue.

Definition at line 17 of file SyncQueues.h.

template<class T>
std::mutex SynchronizedQueue< T >::mut
mutableprotected

mutex for protection

Definition at line 20 of file SyncQueues.h.

template<class T>
std::condition_variable SynchronizedQueue< T >::not_empty
protected

condition variable for not empty notification

Definition at line 23 of file SyncQueues.h.


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