Instance class for a multi-producer, single-consumer circular queue / ring buffer (FIFO). This implementation is lock-free between producers and consumer for the available(), peek(), pop(), and push() type functions, but is guarded to safely allow only a single producer at any instant.
More...
#include <circular_queue_mp.h>
Inherits circular_queue< T, ForEachArg >.
|
| | circular_queue_mp ()=default |
| |
| | circular_queue_mp (const size_t capacity) |
| |
| | circular_queue_mp (circular_queue< T, ForEachArg > &&cq) |
| |
| bool | capacity (const size_t cap) |
| | Resize the queue. The available elements in the queue are preserved. This is not lock-free, but safe, concurrent producer or consumer access is guarded.
|
| |
| bool IRAM_ATTR | push ()=delete |
| |
| bool IRAM_ATTR | push (T &&val) |
| | Move the rvalue parameter into the queue, guarded for multiple concurrent producers.
|
| |
| bool IRAM_ATTR | push (const T &val) |
| | Push a copy of the parameter into the queue, guarded for multiple concurrent producers.
|
| |
| size_t | push_n (const T *buffer, size_t size) |
| | Push copies of multiple elements from a buffer into the queue, in order, beginning at buffer's head. This is guarded for multiple producers, push_n() is atomic.
|
| |
| T & | pop_requeue () |
| | Pops the next available element from the queue, requeues it immediately.
|
| |
| bool | for_each_requeue (const Delegate< bool(T &), ForEachArg > &fun) |
| | Iterate over, pop and optionally requeue each available element from the queue, calling back fun with a reference of every single element. Requeuing is dependent on the return boolean of the callback function. If it returns true, the requeue occurs.
|
| |
|
| | circular_queue () |
| | Constructs a valid, but zero-capacity dummy queue.
|
| |
| | circular_queue (const size_t capacity) |
| | Constructs a queue of the given maximum capacity.
|
| |
| | circular_queue (circular_queue &&cq) |
| |
| | ~circular_queue () |
| |
| | circular_queue (const circular_queue &)=delete |
| |
| circular_queue & | operator= (circular_queue &&cq) |
| |
| circular_queue & | operator= (const circular_queue &)=delete |
| |
| size_t | capacity () const |
| | Get the numer of elements the queue can hold at most.
|
| |
| bool | capacity (const size_t cap) |
| | Resize the queue. The available elements in the queue are preserved. This is not lock-free and concurrent producer or consumer access will lead to corruption.
|
| |
| void | flush () |
| | Discard all data in the queue.
|
| |
| size_t | available () const |
| | Get a snapshot number of elements that can be retrieved by pop.
|
| |
| size_t | available_for_push () const |
| | Get the remaining free elementes for pushing.
|
| |
| T | peek () const |
| | Peek at the next element pop will return without removing it from the queue.
|
| |
| T &IRAM_ATTR | pushpeek () __attribute__((always_inline)) |
| | Peek at the next pending input value.
|
| |
| bool IRAM_ATTR | push () __attribute__((always_inline)) |
| | Release the next pending input value, accessible by pushpeek(), into the queue.
|
| |
| bool IRAM_ATTR | push (T &&val) __attribute__((always_inline)) |
| | Move the rvalue parameter into the queue.
|
| |
| bool IRAM_ATTR | push (const T &val) __attribute__((always_inline)) |
| | Push a copy of the parameter into the queue.
|
| |
| size_t | push_n (const T *buffer, size_t size) |
| | Push copies of multiple elements from a buffer into the queue, in order, beginning at buffer's head.
|
| |
| T | pop () |
| | Pop the next available element from the queue.
|
| |
| size_t | pop_n (T *buffer, size_t size) |
| | Pop multiple elements in ordered sequence from the queue to a buffer. If buffer is nullptr, simply discards up to size elements from the queue.
|
| |
| void | for_each (const Delegate< void(T &&), ForEachArg > &fun) |
| | Iterate over and remove each available element from queue, calling back fun with an rvalue reference of every single element.
|
| |
| void | for_each (Delegate< void(T &&), ForEachArg > fun) |
| |
| bool | for_each_rev_requeue (const Delegate< bool(T &), ForEachArg > &fun) |
| | In reverse order, iterate over, pop and optionally requeue each available element from the queue, calling back fun with a reference of every single element. Requeuing is dependent on the return boolean of the callback function. If it returns true, the requeue occurs.
|
| |
| bool | for_each_rev_requeue (Delegate< bool(T &), ForEachArg > fun) |
| |
template<typename T, typename ForEachArg = void>
class circular_queue_mp< T, ForEachArg >
Instance class for a multi-producer, single-consumer circular queue / ring buffer (FIFO). This implementation is lock-free between producers and consumer for the available(), peek(), pop(), and push() type functions, but is guarded to safely allow only a single producer at any instant.
◆ circular_queue_mp() [1/3]
template<typename T , typename ForEachArg = void>
◆ circular_queue_mp() [2/3]
template<typename T , typename ForEachArg = void>
◆ circular_queue_mp() [3/3]
template<typename T , typename ForEachArg = void>
◆ capacity()
template<typename T , typename ForEachArg = void>
Resize the queue. The available elements in the queue are preserved. This is not lock-free, but safe, concurrent producer or consumer access is guarded.
- Returns
- True if the new capacity could accommodate the present elements in the queue, otherwise nothing is done and false is returned.
◆ for_each_requeue()
template<typename T , typename ForEachArg >
Iterate over, pop and optionally requeue each available element from the queue, calling back fun with a reference of every single element. Requeuing is dependent on the return boolean of the callback function. If it returns true, the requeue occurs.
◆ pop_requeue()
template<typename T , typename ForEachArg >
Pops the next available element from the queue, requeues it immediately.
- Returns
- A reference to the just requeued element, or the default value of type T if the queue is empty.
◆ push() [1/3]
template<typename T , typename ForEachArg = void>
◆ push() [2/3]
template<typename T , typename ForEachArg = void>
Push a copy of the parameter into the queue, guarded for multiple concurrent producers.
- Returns
- true if the queue accepted the value, false if the queue was full.
◆ push() [3/3]
template<typename T , typename ForEachArg = void>
Move the rvalue parameter into the queue, guarded for multiple concurrent producers.
- Returns
- true if the queue accepted the value, false if the queue was full.
◆ push_n()
template<typename T , typename ForEachArg = void>
Push copies of multiple elements from a buffer into the queue, in order, beginning at buffer's head. This is guarded for multiple producers, push_n() is atomic.
- Returns
- The number of elements actually copied into the queue, counted from the buffer head.
◆ m_pushMtx
template<typename T , typename ForEachArg = void>
The documentation for this class was generated from the following file: