firmware
v0.1.2
Chromation Spectrometer Dev-Kit
|
Queue uses a byte array as a circular buffer. More...
#include <Queue.h>
Data Fields | |
volatile uint8_t * | buffer |
buffer is the address of the queue's FIFO buffer More... | |
volatile uint8_t | head |
head advances after a byte is pushed onto the queue More... | |
volatile uint8_t | tail |
tail advances after a byte is popped from the queue More... | |
volatile uint8_t | length |
length is the number of unread bytes in the queue | |
volatile uint8_t | max_length |
max_length is the maximum number of bytes the queue can hold More... | |
Queue uses a byte array as a circular buffer.
A queue is a byte array with data (head, tail) and methods (push, pop) that access linear memory like circular memory. The memory is finite (the queue can fill up) but the user cannot "fall off" the end of the byte array.
Picture the byte array as a closed loop like the numbers on a clock:
Other bytes in the buffer are not in the queue, meaning they cannot be accessed by a pop. These values remain stored in the buffer until overwritten by a push.
A queue is a FIFO (first-in first-out) buffer: pop removes the oldest byte in the queue.
volatile uint8_t* Queue_s::buffer |
volatile uint8_t Queue_s::head |
volatile uint8_t Queue_s::max_length |
volatile uint8_t Queue_s::tail |