Instance class for a single-producer, single-consumer circular queue / ring buffer (FIFO). This implementation is lock-free between producer and consumer for the available(), peek(), pop(), and push() type functions.
More...
|
| | 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< T, ForEachArg >
Instance class for a single-producer, single-consumer circular queue / ring buffer (FIFO). This implementation is lock-free between producer and consumer for the available(), peek(), pop(), and push() type functions.
template<typename T, typename ForEachArg>
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.