PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
msgq.h File Reference
#include <pbl/kernel/types.h>

Data Structures

struct  pbl_msgq
 Fixed-size message ring. More...
 

Macros

#define PBL_MSGQ_INITIALIZER(buffer, size, max)    {.buf = (buffer), .msg_size = (size), .max_msgs = (max)}
 Static initializer for an empty queue.
 
#define PBL_MSGQ_STATIC_BUF(size, max)   ((uint32_t[((size) *(max) + 3) / 4]){0})
 Anonymous, word-aligned storage for a queue.
 
#define PBL_MSGQ_DEFINE(name, size, max)    struct pbl_msgq name = PBL_MSGQ_INITIALIZER(PBL_MSGQ_STATIC_BUF(size, max), size, max)
 Define a queue with its own storage, usable without pbl_msgq_init().
 

Functions

void pbl_msgq_init (struct pbl_msgq *q, void *buf, size_t msg_size, uint32_t max_msgs)
 Initialize a queue in dynamically allocated memory.
 
void pbl_msgq_deinit (struct pbl_msgq *q)
 Release a queue before its memory is reused.
 
int pbl_msgq_put (struct pbl_msgq *q, const void *msg, pbl_timeout_t timeout)
 Append a message.
 
int pbl_msgq_put_front (struct pbl_msgq *q, const void *msg, pbl_timeout_t timeout)
 Prepend a message, so it is received next.
 
int pbl_msgq_get (struct pbl_msgq *q, void *msg, pbl_timeout_t timeout)
 Receive the oldest message.
 
int pbl_msgq_peek (struct pbl_msgq *q, void *msg)
 Copy the oldest message without removing it.
 
void pbl_msgq_purge (struct pbl_msgq *q)
 Discard every message.
 
uint32_t pbl_msgq_num_used (const struct pbl_msgq *q)
 Get the number of queued messages.
 
uint32_t pbl_msgq_num_free (const struct pbl_msgq *q)
 Get the free space of a queue.