Motion Master
|
A simple thread-safe FIFO queue. More...
#include <util.h>
Public Member Functions | |
ThreadSafeQueue ()=default | |
Construct a new empty ThreadSafeQueue. More... | |
ThreadSafeQueue (const ThreadSafeQueue &)=delete | |
Deleted copy constructor. More... | |
ThreadSafeQueue & | operator= (const ThreadSafeQueue &)=delete |
Deleted copy assignment operator. More... | |
void | push (T value) |
Push a new value into the queue. More... | |
std::optional< T > | try_pop () |
Try to pop a value from the queue without blocking. More... | |
T | wait_and_pop () |
Wait for an item to be available and pop it. More... | |
bool | empty () const |
Check whether the queue is empty. More... | |
size_t | size () const |
Get the current number of items in the queue. More... | |
A simple thread-safe FIFO queue.
Provides push, blocking pop, and non-blocking pop operations with thread safety using a mutex and condition variable.
T | Type of elements stored in the queue. |
|
default |
Construct a new empty ThreadSafeQueue.
|
delete |
Deleted copy constructor.
|
inline |
Check whether the queue is empty.
|
delete |
Deleted copy assignment operator.
|
inline |
Push a new value into the queue.
value | Value to push. |
|
inline |
Get the current number of items in the queue.
Note: size may change immediately after this call in concurrent use.
|
inline |
Try to pop a value from the queue without blocking.
|
inline |
Wait for an item to be available and pop it.
Blocks until an item is available.