Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
FixedQueue< T, SIZE > Class Template Reference

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

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.
 

Detailed Description

template<class T, uint8_t SIZE>
class FixedQueue< T, SIZE >

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).

Deprecated:
, use DeviceBuffer instead.
Todo:
(balazs.racz) replace uses of this class with DeviceBuffer (to enable select support for example).

Definition at line 55 of file FixedQueue.hxx.

Constructor & Destructor Documentation

◆ FixedQueue()

template<class T , uint8_t SIZE>
FixedQueue< T, SIZE >::FixedQueue ( )
inline

Definition at line 57 of file FixedQueue.hxx.

Member Function Documentation

◆ back()

template<class T , uint8_t SIZE>
T & FixedQueue< T, SIZE >::back ( )
inline

Returns the space to write the next element to.

Definition at line 85 of file FixedQueue.hxx.

◆ commit_back()

template<class T , uint8_t SIZE>
void FixedQueue< T, SIZE >::commit_back ( )
inline

Commits the oldest entry reserved by noncommit_back.

Definition at line 119 of file FixedQueue.hxx.

◆ empty()

template<class T , uint8_t SIZE>
bool FixedQueue< T, SIZE >::empty ( )
inline
Returns
true if there is no entry in the queue.

Definition at line 65 of file FixedQueue.hxx.

◆ front()

template<class T , uint8_t SIZE>
T & FixedQueue< T, SIZE >::front ( )
inline

Returns the head of the FIFO (next element to read).

Definition at line 72 of file FixedQueue.hxx.

◆ full()

template<class T , uint8_t SIZE>
bool FixedQueue< T, SIZE >::full ( )
inline
Returns
true if the queue cannot accept more elements.

Definition at line 67 of file FixedQueue.hxx.

◆ has_noncommit_space()

template<class T , uint8_t SIZE>
bool FixedQueue< T, SIZE >::has_noncommit_space ( )
inline
Returns
true if we can do a noncommit back.

Definition at line 111 of file FixedQueue.hxx.

◆ increment_back()

template<class T , uint8_t SIZE>
void FixedQueue< T, SIZE >::increment_back ( )
inline

Commits the element at back() into the queue.

Definition at line 91 of file FixedQueue.hxx.

◆ increment_front()

template<class T , uint8_t SIZE>
void FixedQueue< T, SIZE >::increment_front ( )
inline

Removes the head of the FIFO from the queue.

Definition at line 78 of file FixedQueue.hxx.

◆ noncommit_back()

template<class T , uint8_t SIZE>
void FixedQueue< T, SIZE >::noncommit_back ( )
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.

◆ size()

template<class T , uint8_t SIZE>
size_t FixedQueue< T, SIZE >::size ( )
inline
Returns
the current number of entries in the queue.

Definition at line 69 of file FixedQueue.hxx.

Member Data Documentation

◆ count_

template<class T , uint8_t SIZE>
volatile uint8_t FixedQueue< T, SIZE >::count_
private

How many elements are there in the queue.

Definition at line 133 of file FixedQueue.hxx.

◆ rdIndex_

template<class T , uint8_t SIZE>
uint8_t FixedQueue< T, SIZE >::rdIndex_
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.

◆ storage_

template<class T , uint8_t SIZE>
T FixedQueue< T, SIZE >::storage_[SIZE]
private

Payload of elements stored.

Definition at line 126 of file FixedQueue.hxx.

◆ wrIndex_

template<class T , uint8_t SIZE>
uint8_t FixedQueue< T, SIZE >::wrIndex_
private

The index of the element where to write the next input to.

Definition at line 131 of file FixedQueue.hxx.


The documentation for this class was generated from the following file: