Template Class queue_t

Inheritance Relationships

Base Type

  • public std::list< type >

Class Documentation

template<typename type>
class queue_t : public std::list<type>

Thread-safe queue wrapper around std::list.

Template Parameters:

type – Type of elements stored in the queue.

Public Types

using shared_ptr = std::shared_ptr<queue_t<type>>

Typedefs.

Public Functions

inline size_t push_back_safe(const type item_)

Simple thread-safe function that inserts an element at the end of the queue

Parameters:

item_ – Element appended to the back of the queue.

Returns:

Queue size after the insertion.

inline bool empty_safe() const

Simple thread-safe function that checks if the queue is empty

Returns:

true when no elements are stored, false otherwise.

inline size_t size_safe() const

Simple thread-safe function that returns the size of the queue

Returns:

Number of elements currently stored in the queue.

inline output_t<type> pop_front()

Non thread-safe function to pop the front (first) element of the queue

Returns:

Front element wrapped in output_t, or fail_t::IS_EMPTY.

inline output_t<type> pop_front_safe()

Thread-safe function to pop the front (first) element of the queue

Returns:

Front element wrapped in output_t, or fail_t::IS_EMPTY.

inline vector_t<type> pop_front(const size_t numberElements_)

Non-thread-safe function to pop the front (first) n elements.

Parameters:

numberElements_ – Maximum number of elements to remove.

Returns:

Output vector with the popped elements.

inline vector_t<type> pop_front_safe(const size_t numberElements_)

Thread-safe function to pop the front (first) n elements.

Parameters:

numberElements_ – Maximum number of elements to remove.

Returns:

Output vector with the popped elements.

inline void lock_read() const

Shared mutex lock functions.

inline void unlock_read() const

Shared mutex unlock functions.

inline void lock() const

Exclusive mutex lock functions.

inline void unlock() const

Exclusive mutex unlock functions.

inline void print(const std::string &prefix_) const

Print all elements in the queue (for debugging purposes)

Parameters:

prefix_ – Prefix printed before the queue contents.

Private Members

mutable std::shared_mutex _mutex

Mutex for thread safety.