|
Lightweight 0.20260617.0
|
#include <ThreadSafeQueue.hpp>
Public Member Functions | |
| void | Push (T item) |
| bool | WaitAndPop (T &item) |
| void | MarkFinished () |
| bool | Empty () const |
| size_t | Size () const |
Thread-safe queue with blocking wait semantics.
This queue allows multiple producer and consumer threads to safely enqueue and dequeue items. Consumers block on WaitAndPop until an item is available or the queue is marked as finished.
It is a thin facade over detail::BlockingQueue (the shared blocking-FIFO primitive), so the locking/wait logic lives in exactly one place rather than being hand-rolled here.
| T | The type of items stored in the queue. |
Definition at line 24 of file ThreadSafeQueue.hpp.
|
inline |
Pushes an item onto the queue and notifies one waiting consumer.
| item | The item to push onto the queue. |
Definition at line 30 of file ThreadSafeQueue.hpp.
|
inline |
Blocks until an item is available or the queue is finished.
This method will block the calling thread until either:
| item | Output parameter to receive the popped item. |
Definition at line 43 of file ThreadSafeQueue.hpp.
|
inline |
Signals that no more items will be added.
After this call, WaitAndPop will return false once the queue is empty. All waiting consumers will be notified.
Definition at line 52 of file ThreadSafeQueue.hpp.
|
inline |
Checks if the queue is empty.
Definition at line 60 of file ThreadSafeQueue.hpp.
|
inline |
Returns the current size of the queue.
Definition at line 68 of file ThreadSafeQueue.hpp.