|
Lamp-Da 0.1
A compact lantern project
|
Fixed capacity FIFO queue, guarded by a mutex. Push and pop can be called from any thread, but not from an interrupt. The lock is only held while copying an item, never while the caller handles it. More...
#include <thread_safe_queue.h>
Public Member Functions | |
| ThreadSafeQueue (const ThreadSafeQueue &)=delete | |
| ThreadSafeQueue & | operator= (const ThreadSafeQueue &)=delete |
| bool | push (const T &item) |
| Push an item at the end of the queue. | |
| etl::optional< T > | pop () |
| Pop the oldest item. | |
| size_t | size () |
| Return the number of stored items. | |
| void | clear () |
| Drop all stored items. | |
Static Public Member Functions | |
| static constexpr size_t | capacity () |
| Maximum number of stored items. | |
Fixed capacity FIFO queue, guarded by a mutex. Push and pop can be called from any thread, but not from an interrupt. The lock is only held while copying an item, never while the caller handles it.
|
inline |
Pop the oldest item.
|
inline |
Push an item at the end of the queue.