KM3NeT CLB
2.0
KM3NeT CLB v2 Embedded Software
|
Queue is created in statically allocated memory. More...
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | QueueDescr |
Queue descriptor. More... | |
struct | Queue |
Queue state. More... | |
Macros | |
#define | Q_INIT(NAME, ENTRY_SIZE, CAPACITY) |
Convenience Macro, defines and inits queue. More... | |
Functions | |
void * | qQueueIP (Queue *q) |
Queue data to the end of the queue in place. More... | |
static bool | qQueue (Queue *q, void *data) |
Queue data to the end of the queue. More... | |
bool | qContains (Queue *q, void *data) |
Iterates the queue to check for an element. More... | |
void * | qDeQueueIP (Queue *q) |
Dequeue an element from the front of the queue in place. More... | |
static bool | qDeQueue (Queue *q, void *data) |
Dequeue an element from the front of the queue. More... | |
bool | qRemoveBack (Queue *q) |
Delete element from the back for the queue. More... | |
static void * | qFirst (Queue *q) |
Peek at the first element in the queue. More... | |
static void * | qNext (Queue *q, void *ptr) |
Peek at the next element in the queue. More... | |
static bool | qFull (Queue *q) |
Returns whether or not the queue is full. More... | |
static void | qReset (Queue *q) |
Resets the queue. More... | |
Queue is created in statically allocated memory.
Capacity and size can not be changed during runtime. Note that the queue definition is broken up in two parts, the descriptor and the actual queue.
To simplify creation of the queue use the Q_INIT macro.
Definition in file queue.h.
#define Q_INIT | ( | NAME, | |
ENTRY_SIZE, | |||
CAPACITY | |||
) |
Convenience Macro, defines and inits queue.
Example of how to use it:
Must be used outside of any function scope.
NAME | Name of the queue pointer. |
ENTRY_SIZE | Size in bytes of one element (use sizeof()). |
CAPACITY | Maximum number of elements in queue. |
bool qContains | ( | Queue * | q, |
void * | data | ||
) |
Iterates the queue to check for an element.
Searching is done by iterating though all elements and performance will drop with respect to the queue length.
q | The queue. |
data | The element to check for. |
|
inlinestatic |
void* qDeQueueIP | ( | Queue * | q | ) |
Dequeue an element from the front of the queue in place.
A pointer to the data will be given. Take care not to overwrite any more bytes than the size of the element.
The data is valid for as long as no elements are written to the queue.
q | The queue. |
|
inlinestatic |
Peek at the first element in the queue.
Returns a pointer to the first element in the queue, without dequeuing it. Note that the pointer is only valid for as long as the element is in the queue.
Use together with qNext to create an iterator.
q | The queue structure. |
Pointer | to the first element in the queue, or NULL if the queue is empty. |
|
inlinestatic |
|
inlinestatic |
Peek at the next element in the queue.
Returns a pointer to the next element in the queue, without dequeuing it. Note that the pointer is only valid for as long as the element is in the queue.
Can be used together with qFirst to iterate though all elements of a queue. For example:
q | The queue structure. |
Pointer | to the net element in the queue, or NULL if you reached the end of the queue. |
|
inlinestatic |
void* qQueueIP | ( | Queue * | q | ) |
Queue data to the end of the queue in place.
You can write the element data to the returned pointer, but no not write any further than the size of the entry.
q | The queue. |
bool qRemoveBack | ( | Queue * | q | ) |