R-Type
Public Member Functions | List of all members
SafeQueue< T > Class Template Reference

A queue class that is thread safe. More...

#include <SafeQueue.hpp>

Inheritance diagram for SafeQueue< T >:
ISafeQueue< T >

Public Member Functions

 SafeQueue ()=default
 
 ~SafeQueue ()=default
 Destructor. More...
 
void push (T value) override
 Push in queue, lock a mutex while pushing the value. More...
 
bool tryPop (T &value) override
 Try to pop a value from the queue, lock a mutex while trying to pop the value. More...
 
pop () override
 Pop a value from the queue, lock a mutex and wait if the queue is empty. More...
 
size_t size () const
 Returns the current size of the queue. More...
 
- Public Member Functions inherited from ISafeQueue< T >
virtual ~ISafeQueue ()=default
 Destructor. More...
 

Detailed Description

template<typename T>
class SafeQueue< T >

A queue class that is thread safe.

Template Parameters
TThe type contained in the queue

Constructor & Destructor Documentation

◆ SafeQueue()

template<typename T >
SafeQueue< T >::SafeQueue ( )
default

◆ ~SafeQueue()

template<typename T >
SafeQueue< T >::~SafeQueue ( )
default

Destructor.

Member Function Documentation

◆ pop()

template<typename T >
T SafeQueue< T >::pop ( )
inlineoverridevirtual

Pop a value from the queue, lock a mutex and wait if the queue is empty.

Returns
The popped value

Implements ISafeQueue< T >.

◆ push()

template<typename T >
void SafeQueue< T >::push ( value)
inlineoverridevirtual

Push in queue, lock a mutex while pushing the value.

Parameters
valueValue to be pushed

Implements ISafeQueue< T >.

◆ size()

template<typename T >
size_t SafeQueue< T >::size ( ) const
inline

Returns the current size of the queue.

Returns
size_t of the size of the queue.

◆ tryPop()

template<typename T >
bool SafeQueue< T >::tryPop ( T &  value)
inlineoverridevirtual

Try to pop a value from the queue, lock a mutex while trying to pop the value.

Parameters
valueReference to be filled withthe popped value
Returns
true if the value was successfully popped, false if there was no value in queue

Implements ISafeQueue< T >.


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