RobWorkProject  24.5.15-
Public Member Functions | List of all members
ThreadSafeQueue< T > Class Template Reference

Queue class which is thread safe, eg. multiple threads may use it at the same time. More...

#include <ThreadSafeQueue.hpp>

Public Member Functions

 ThreadSafeQueue ()
 constructor
 
bool empty ()
 test if the queue is empty More...
 
void push (T wp)
 add data to the queue More...
 
bool try_pop (T *wp)
 try to pop data from the queue. If no data is available then false is returned if data is available then true is returned and wp is set. More...
 
bool pop (T *wp)
 pop data from the queue in blocking manner. That is it will wait until data is added to the queue if it is initially empty. More...
 
bool has (T value)
 test if the queue contain a specific data value. This is slow O(N) so keep that in mind when using it. More...
 
bool popAndPrint (T *wp)
 Pop data from the queue in blocking manner and print the element to standard output. More...
 
size_t size ()
 Get the size of the queue. More...
 

Detailed Description

template<class T>
class rw::common::ThreadSafeQueue< T >

Queue class which is thread safe, eg. multiple threads may use it at the same time.

Member Function Documentation

◆ empty()

bool empty ( )
inline

test if the queue is empty

Returns
true if queue is empty, false otherwise

◆ has()

bool has ( value)
inline

test if the queue contain a specific data value. This is slow O(N) so keep that in mind when using it.

Parameters
value[in] the value to compare with.
Returns

◆ pop()

bool pop ( T *  wp)
inline

pop data from the queue in blocking manner. That is it will wait until data is added to the queue if it is initially empty.

Parameters
wp[out] data that is popped from the queue
Returns

◆ popAndPrint()

bool popAndPrint ( T *  wp)
inline

Pop data from the queue in blocking manner and print the element to standard output.

Parameters
wp[out] data that is popped from the queue.
Returns
true.

◆ push()

void push ( wp)
inline

add data to the queue

Parameters
wp[in] data to add to queue

◆ size()

size_t size ( )
inline

Get the size of the queue.

Returns
the size.

◆ try_pop()

bool try_pop ( T *  wp)
inline

try to pop data from the queue. If no data is available then false is returned if data is available then true is returned and wp is set.

Parameters
wp[out]
Returns
true is wp set, false otherwise

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