|
Open Model Railroad Network (OpenMRN)
|
This structure is safe to use from an interrupt context and a regular context at the same time, provided that. More...
#include <FixedQueue.hxx>
Public Member Functions | |
| bool | empty () |
| bool | full () |
| size_t | size () |
| T & | front () |
| Returns the head of the FIFO (next element to read). | |
| void | increment_front () |
| Removes the head of the FIFO from the queue. | |
| T & | back () |
| Returns the space to write the next element to. | |
| void | increment_back () |
| Commits the element at back() into the queue. | |
| void | noncommit_back () |
| Increments the back pointer without committing the entry into the queue. | |
| bool | has_noncommit_space () |
| void | commit_back () |
| Commits the oldest entry reserved by noncommit_back. | |
Private Attributes | |
| T | storage_ [SIZE] |
| Payload of elements stored. | |
| uint8_t | rdIndex_ |
| The index of the element to return next upon a read. | |
| uint8_t | wrIndex_ |
| The index of the element where to write the next input to. | |
| volatile uint8_t | count_ |
| How many elements are there in the queue. | |
This structure is safe to use from an interrupt context and a regular context at the same time, provided that.
. one context uses only the front() and the other only the back() functions.
. ++ and – are compiled into atomic operations on the processor (on the count_ variable).
Definition at line 55 of file FixedQueue.hxx.
|
inline |
Definition at line 57 of file FixedQueue.hxx.
|
inline |
Returns the space to write the next element to.
Definition at line 85 of file FixedQueue.hxx.
|
inline |
Commits the oldest entry reserved by noncommit_back.
Definition at line 119 of file FixedQueue.hxx.
|
inline |
Definition at line 65 of file FixedQueue.hxx.
|
inline |
Returns the head of the FIFO (next element to read).
Definition at line 72 of file FixedQueue.hxx.
|
inline |
Definition at line 67 of file FixedQueue.hxx.
|
inline |
Definition at line 111 of file FixedQueue.hxx.
|
inline |
Commits the element at back() into the queue.
Definition at line 91 of file FixedQueue.hxx.
|
inline |
Removes the head of the FIFO from the queue.
Definition at line 78 of file FixedQueue.hxx.
|
inline |
Increments the back pointer without committing the entry into the queue.
This essentially reserves an entry in the queue for filling in, without making that entry available for reading. Must be followed by a commit_back call when filling in the entry is finished. An arbitrary number of such entries can be reserved (up to the number of free entries in the queue).
Definition at line 105 of file FixedQueue.hxx.
|
inline |
Definition at line 69 of file FixedQueue.hxx.
|
private |
How many elements are there in the queue.
Definition at line 133 of file FixedQueue.hxx.
|
private |
The index of the element to return next upon a read.
This element is typically full (unless the queue is empty itself).
Definition at line 129 of file FixedQueue.hxx.
|
private |
Payload of elements stored.
Definition at line 126 of file FixedQueue.hxx.
|
private |
The index of the element where to write the next input to.
Definition at line 131 of file FixedQueue.hxx.