data.fifo ≡
template < typename T, auto Size, bool EnqueueBlocking = true, bool DequeueBlocking = true > class FIFO §
Basic FIFO.
Parameters
-
typename TType for each entry of the FIFO.
-
auto SizeMaximum number of entries that can be stored.
-
bool EnqueueBlocking = true
Block on enqueue if the FIFO is full until an entry frees up. By default this is true. Otherwise, the caller must ensure that the FIFO is not full.
-
bool DequeueBlocking = true
Block on dequeue if the FIFO is empty until an entry arrives. By default, this is true. Otherwise, the caller must ensure that the FIFO is not empty.
Methods
-
inline count_t<Size> count() §
Return the number of elements that have been written and not read. Note that this can be out of date the instant its read due to other threads reading/writing to the FIFO. This cannot be used for checking empty/full for non-blocking versions of the FIFO.
-
T dequeue() §
Read one entry from FIFO. Block if FIFO is empty and
DequeueBlockingis true. -
void enqueue(T value) §
Write one entry to the FIFO. Block if FIFO is full and
EnqueueBlockingis true.
Invariants
-
(0 == (Size & (Size - 1)))
Sizemust be a power of 2.
template <typename T, auto Size, bool DequeueBlocking = true> class FIFO_store_and_forward §
Store and forward FIFO.
Parameters
-
typename TType for each entry of the FIFO.
-
auto SizeMaximum number of entries that can be stored.
-
bool DequeueBlocking = true
Block on dequeue if the FIFO is empty until an entry arrives. By default, this is true. Otherwise, the caller must ensure that the FIFO is not empty.
Methods
-
inline count_t<Size> count() §
Return the number of elements that have been written and not read. Note that this can be out of date the instant its read due to other threads reading/writing to the FIFO. This cannot be used for checking empty/full for non-blocking versions of the FIFO.
-
T dequeue() §
Read one entry from FIFO. Block if FIFO is empty and
DequeueBlockingis true. -
count_t<Size> enqueue(T value, bool releaseDeferredDequeues) §
Write one entry to the FIFO. Block if FIFO is full. Return the number of dequeue calls that were released.
Invariants
-
(0 == (Size & (Size - 1)))
Sizemust be a power of 2.
template <typename T, auto Size> class fifo_nb §
A FIFO that enables polling read/write operations and conditionally reading an element based on the value of that element.
Parameters
-
typename TType for each entry of the FIFO.
-
auto SizeMaximum number of entries that can be stored.
Methods
-
inline bool full() §
Return true if no more entries can be enqueued. Typical usage is to call
fullandreserve_enqueuein the same atomic block. -
inline void reserve_enqueue() §
Reserve one slot, so that data can be safely written into the FIFO at a future point in time. Typical usage is to call
fullandreserve_enqueuein the same atomic block. Each call toreserve_enqueuemust be paired with 1 call toenqueue. Theenqueuecall does not need to be in an atomic block with the call toreserve_enqueue. -
inline bool check_and_reserve() §
Helper function that checks fifo state and conditionally reserves a slot. If the fifo is not full, then this reserves one slot and returns true. Return false otherwise.
-
void enqueue(T value) §
Write one data item to the queue.
reserve_enqueuemust have been called previously. -
void enqueue_blocking(T value) §
Helper function that blocks the current thread until the output is not full and then enqueues one item.
-
inline bool empty() §
Return true if there is no more data in the queue. Typical usage is to call
emptyin the same atomic block asfrontandpop. -
inline T front() §
Return the value at the head of the queue. Typical usage is to call
emptyin the same atomic block asfrontandpop. -
inline void pop() §
Remove 1 item from the queue. Typical usage is to call
emptyin the same atomic block asfrontandpop.
Invariants
-
(0 == (Size & (Size - 1)))
Sizemust be a power of 2.