Template Class Queue

Class Documentation

template<typename T>
class Queue

Thread-safe queue. Particularly useful when multiple threads need to write to and/or read from a queue.

Public Functions

inline auto size() const noexcept

Get the size of the queue.

Returns:

Queue size

inline auto empty() const noexcept

Check if the queue is empty.

Returns:

True if the queue is empty, otherwise false

inline void push(T value) noexcept

Push data into the queue.

Parameters:

value – Data to push into the queue

inline void clear() noexcept

Clear the queue.

inline auto pop(std::chrono::nanoseconds wait_time = {}) -> std::optional<T>

Wait for given duration then pop from the queue and return the element.

Parameters:

wait_time – Maximum time to wait for queue to be non-empty

Returns:

Data popped from the queue or error