15#include <condition_variable>
94 std::unique_lock<std::mutex> lock(
m_mutex);
124 std::unique_lock<std::mutex> lock(
m_mutex);
133 out = std::move(
m_queue.front());
149 std::scoped_lock<std::mutex> lock(
m_mutex);
164 std::scoped_lock<std::mutex> lock(
m_mutex);
187 std::scoped_lock<std::mutex> lock(
m_mutex);
202 std::condition_variable
204 std::condition_variable
Assertion macros and utilities based on the PPK_ASSERT library.
A thread-safe, optionally bounded queue with blocking push and pop operations.
std::queue< T > m_queue
Underlying queue holding the data.
std::condition_variable m_consumerConditionVariable
Condition variable for consumer blocking.
bool done() const
Returns whether the queue is marked done.
bool full() const
Checks if the queue is full.
SafeQueue(const SafeQueue &)=delete
Deleted copy constructor to prevent copying.
void push(T &&item)
Push an item into the queue.
size_t size() const
Returns the current size of the queue.
void producerFinished()
Signals that the producer has finished producing items.
std::condition_variable m_producerConditionVariable
Condition variable for producer blocking.
bool empty() const
Checks if the queue is empty.
std::mutex m_mutex
Mutex protecting the queue and state.
bool m_done
Flag indicating the queue is done.
SafeQueue(size_t max_size=0)
Constructs a SafeQueue with an optional maximum size.
bool pop(T &out)
Pop an item from the queue.
SafeQueue & operator=(const SafeQueue &)=delete
Deleted copy assignment operator to prevent copying.
size_t m_maxSize
Maximum queue size (0 means unbounded).
#define IRSOL_ASSERT_ERROR
Error-level assertion macro.