DUNE: Uniform Navigational Environment  2019.02.1
DUNE::Concurrency::TSQueue< T > Class Template Reference

Detailed Description

template<typename T>
class DUNE::Concurrency::TSQueue< T >

The TSQueue is a thread-safe implementation of a FIFO (first-in, first-out) data structure.

Public Member Functions

 TSQueue (void)
 
void push (const T &v)
 
pop (void)
 
bool waitForItems (double timeout=-1.0)
 
bool empty (void)
 
unsigned size (void)
 
void close (void)
 
bool closed (void)
 

Constructor & Destructor Documentation

template<typename T>
DUNE::Concurrency::TSQueue< T >::TSQueue ( void  )
inline

Constructor.

Member Function Documentation

template<typename T>
void DUNE::Concurrency::TSQueue< T >::close ( void  )
inline
template<typename T>
bool DUNE::Concurrency::TSQueue< T >::closed ( void  )
inline
template<typename T>
bool DUNE::Concurrency::TSQueue< T >::empty ( void  )
inline

Verify if the queue has elements.

Returns
true if the queue has no elements, false otherwise.

Referenced by DUNE::Concurrency::TSQueue< UCTK::DUNE::Hardware::UCTK::Frame * >::waitForItems().

template<typename T>
T DUNE::Concurrency::TSQueue< T >::pop ( void  )
inline

Retrieve the first element of the queue and removes it from the queue.

Returns
first element of the queue.

Referenced by DUNE::Hardware::BasicModem::readLine(), and DUNE::Hardware::BasicModem::readRaw().

template<typename T>
void DUNE::Concurrency::TSQueue< T >::push ( const T &  v)
inline

Adds an element to the end of the queue.

Signaling waiting threads.

Parameters
vvariable to insert.

Referenced by DUNE::Hardware::BasicModem::flushInput().

template<typename T>
unsigned DUNE::Concurrency::TSQueue< T >::size ( void  )
inline

Retrieve the number of elements currently in the queue.

Returns
number of elements of the queue.
template<typename T>
bool DUNE::Concurrency::TSQueue< T >::waitForItems ( double  timeout = -1.0)
inline

Wait for items to be available.

Parameters
timeouttimeout in seconds, use a negative number to wait forever.
Returns
true if at least one element is available, false otherwise.

Referenced by DUNE::Hardware::BasicModem::readLine(), and DUNE::Hardware::BasicModem::readRaw().

Collaboration diagram for DUNE::Concurrency::TSQueue< T >:
Collaboration graph