SELKIELogger
1.0.0
|
Classes | |
struct | msgqueue |
Represent a simple FIFO message queue. More... | |
struct | queueitem |
Typedefs | |
typedef struct queueitem | queueitem |
Each queue item is a message and pointer to the next queue entry, if any. | |
typedef struct msgqueue | msgqueue |
Represent a simple FIFO message queue. More... | |
Functions | |
bool | queue_init (msgqueue *queue) |
Ensure queue structure is set to known good values and marked valid. More... | |
void | queue_destroy (msgqueue *queue) |
Invalidate queue and destroy all contents. More... | |
bool | queue_push (msgqueue *queue, msg_t *item) |
Add a message to the tail of the queue. More... | |
bool | queue_push_qi (msgqueue *queue, queueitem *item) |
Add a queue item to the tail of the queue. More... | |
msg_t * | queue_pop (msgqueue *queue) |
Remove topmost item from the queue and return it, if queue is not empty. More... | |
int | queue_count (const msgqueue *queue) |
Iterate over queue and return current number of items. More... | |
Represent a simple FIFO message queue.
Represents a queue of items starting at msgqueue.head, with the last item at or near msgqueue.tail.
The queue is protected by the mutex at msgqueue.lock, and will only have items added and removed while msgqueue.valid remains true.
int queue_count | ( | const msgqueue * | queue | ) |
void queue_destroy | ( | msgqueue * | queue | ) |
bool queue_init | ( | msgqueue * | queue | ) |
Ensure queue structure is set to known good values and marked valid.
Will not re-initialise a queue if it is still valid or has a head or tail value set. Other threads might be able to add entries to the queue between the queue being marked valid and this function returning to the caller.
[in] | queue | Pointer to queue structure to be initialised |
Remove topmost item from the queue and return it, if queue is not empty.
Atomically remove the first entry in the queue and return it. The underlying queue item is freed, but our caller must destroy and free the message itself.
The queue item is freed, but the caller is responsible for destroying and freeing the message itself after use (i.e. the caller now owns the message, not the queue or the sending function).
[in] | queue | Pointer to queue |
Add a message to the tail of the queue.
Messages are wrapped into a queue item structure, and passed immediately to queue_push_qi()
[in] | queue | Pointer to queue |
[in] | msg | Pointer to message |
Add a queue item to the tail of the queue.
Will not append to an invalid queue.
Once pushed to the queue, the queue owns the message embedded in item
and the caller should not destroy or free it. That will be handled in queue_destroy() or the function responsible for consuming items out of the queue.
[in] | queue | Pointer to queue |
[in] | item | Pointer to a queue item |