|
HPC_Voxel_Engine 0.2.0
High-Performance C++ Voxel Engine
|
A thread-safe FIFO queue wrapper using mutexes and condition variables. Designed for producer-consumer scenarios (like ThreadPools). More...
#include <src/core/ThreadSafeQueue.h>

Public Member Functions | |
| ThreadSafeQueue ()=default | |
| ThreadSafeQueue (const ThreadSafeQueue &)=delete | |
| ThreadSafeQueue & | operator= (const ThreadSafeQueue &)=delete |
| void | push (T &&objValue) |
| Pushes a value into the queue (Move semantics). | |
| void | push (const T &objValue) |
| Pushes a value into the queue (Copy semantics). | |
| bool | wait_and_pop (T &objValue) |
| Waits until the queue is not empty, then pops the front element. | |
| std::optional< T > | try_pop () |
| Non-blocking attempt to pop an item. | |
| bool | empty () const |
| void | invalidate () |
| Wakes up all waiting threads effectively cancelling the wait. | |
Private Attributes | |
| std::queue< T > | m_queJobs |
| std::mutex | m_objMutex |
| std::condition_variable | m_objContVar |
| std::atomic< bool > | m_bInvalidated = false |
A thread-safe FIFO queue wrapper using mutexes and condition variables. Designed for producer-consumer scenarios (like ThreadPools).
|
default |
|
delete |
|
inline |
|
inline |
Wakes up all waiting threads effectively cancelling the wait.

|
delete |
|
inline |
Pushes a value into the queue (Copy semantics).
|
inline |
Pushes a value into the queue (Move semantics).

|
inline |
Non-blocking attempt to pop an item.

|
inline |
Waits until the queue is not empty, then pops the front element.
| objValue | Reference to store the popped value. |

|
private |
|
private |
|
mutableprivate |
|
private |