UTILLib 2.0
Common C++ library with utilities.
Loading...
Searching...
No Matches
util::log::ThreadSafeQueue< T > Class Template Reference

Implements a thread-safe queue. More...

#include <threadsafequeue.h>

Public Member Functions

 ThreadSafeQueue (const ThreadSafeQueue &)=delete
ThreadSafeQueueoperator= (const ThreadSafeQueue &)=delete
void Put (std::unique_ptr< T > &value)
 Adds a value at the end of the queue.
bool Get (std::unique_ptr< T > &dest, bool block)
 Fetch the first object from the queue.
bool Empty () const
 Returns true if the queue is empty.
size_t Size () const
 Returns number of items in the queue.
void Clear ()
 Clears the queue.
void Start ()
 Restarts the queue.
void Stop ()
 Stops all blocking Get() calls.

Detailed Description

template<typename T>
class util::log::ThreadSafeQueue< T >

class ThreadSafeQueue threadsafequeue.h "util/threadsafequeue.h"

Implements a thread-safe queue based upon a std::queue. The queue uses stores the objects with smart pointers.

Template Parameters
TType of object to store.

Member Function Documentation

◆ Empty()

template<typename T>
bool util::log::ThreadSafeQueue< T >::Empty ( ) const
nodiscard

Returns true if the queue is empty.

Returns
True if list is empty.

◆ Get()

template<typename T>
bool util::log::ThreadSafeQueue< T >::Get ( std::unique_ptr< T > & dest,
bool block )
nodiscard

Gets the first object in the queue. The function may block until a value is available. Deleting the queue will unblock the call and returning false.

Parameters
destReturning object
blockTrue if the function should block until a value is available.
Returns
True if a value was returned.

◆ Put()

template<typename T>
void util::log::ThreadSafeQueue< T >::Put ( std::unique_ptr< T > & value)

Add a value last in the queue.

Parameters
value

◆ Size()

template<typename T>
size_t util::log::ThreadSafeQueue< T >::Size ( ) const
nodiscard
Returns
Number of items in the queue.

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