DUNE: Uniform Navigational Environment  2024.09.0
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 pop (T &value)
 
bool waitForItems (double timeout=-1.0)
 
bool empty (void)
 
unsigned size (void)
 
void close (void)
 
bool closed (void)
 

Constructor & Destructor Documentation

◆ TSQueue()

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

Constructor.

Member Function Documentation

◆ close()

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

◆ closed()

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

◆ empty()

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< DUNE::IMC::Message *>::waitForItems().

◆ pop() [1/2]

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(), DUNE::Hardware::BasicModem::readRaw(), and DUNE::Hardware::BasicModem::setReadMode().

◆ pop() [2/2]

template<typename T>
bool DUNE::Concurrency::TSQueue< T >::pop ( T &  value)
inline

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

Parameters
[in,out]valuewhere to store the popped value.
Returns
true if an element was popped, false otherwise.

◆ push()

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(), and DUNE::Hardware::BasicModem::setReadMode().

◆ size()

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.

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

◆ waitForItems()

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