Argon RTOS
1.3.0
Tiny embedded real-time kernel
|
Queue API.
Classes | |
struct | ar_queue_t |
Queue. More... | |
class | Ar::Queue |
A blocking queue for inter-thread messaging. More... | |
class | Ar::StaticQueue< T, N > |
Template class to help statically allocate a Queue. More... | |
Queues | |
ar_status_t | ar_queue_create (ar_queue_t *queue, const char *name, void *storage, unsigned elementSize, unsigned capacity) |
Create a new queue. More... | |
ar_status_t | ar_queue_delete (ar_queue_t *queue) |
Delete an existing queue. More... | |
ar_status_t | ar_queue_send (ar_queue_t *queue, const void *element, uint32_t timeout) |
Add an item to the queue. More... | |
ar_status_t | ar_queue_receive (ar_queue_t *queue, void *element, uint32_t timeout) |
Remove an item from the queue. More... | |
bool | ar_queue_is_empty (ar_queue_t *queue) |
Returns whether the queue is currently empty. More... | |
uint32_t | ar_queue_get_count (ar_queue_t *queue) |
Returns the current number of elements in the queue. More... | |
const char * | ar_queue_get_name (ar_queue_t *queue) |
Get the queue's name. More... | |
ar_status_t ar_queue_create | ( | ar_queue_t * | queue, |
const char * | name, | ||
void * | storage, | ||
unsigned | elementSize, | ||
unsigned | capacity | ||
) |
Create a new queue.
queue | The storage for the new queue object. |
name | The new queue's name. |
storage | Pointer to a buffer used to store queue elements. The buffer must be at least elementSize * capacity bytes big. |
elementSize | Size in bytes of each element in the queue. |
capacity | The number of elements that the buffer pointed to by storage will hold. |
kArSuccess | The queue was initialised. |
ar_status_t ar_queue_delete | ( | ar_queue_t * | queue | ) |
Delete an existing queue.
queue | The queue object. |
uint32_t ar_queue_get_count | ( | ar_queue_t * | queue | ) |
Returns the current number of elements in the queue.
queue | The queue object. |
const char* ar_queue_get_name | ( | ar_queue_t * | queue | ) |
Get the queue's name.
queue | The queue object. |
bool ar_queue_is_empty | ( | ar_queue_t * | queue | ) |
Returns whether the queue is currently empty.
queue | The queue object. |
ar_status_t ar_queue_receive | ( | ar_queue_t * | queue, |
void * | element, | ||
uint32_t | timeout | ||
) |
Remove an item from the queue.
queue | The queue object. | |
[out] | element | |
timeout | The maximum number of milliseconds that the caller is willing to wait in a blocked state before an element is received. If this value is 0, or kArNoTimeout, then this method will return immediately if the queue is empty. Setting the timeout to kArInfiniteTimeout will cause the thread to wait forever for receive an element. |
kArSuccess | |
kArQueueEmptyError |
ar_status_t ar_queue_send | ( | ar_queue_t * | queue, |
const void * | element, | ||
uint32_t | timeout | ||
) |
Add an item to the queue.
The caller will block if the queue is full.
queue | The queue object. |
element | Pointer to the element to post to the queue. The element size was specified in the init() call. |
timeout | The maximum number of milliseconds that the caller is willing to wait in a blocked state before the element can be sent. If this value is 0, or kArNoTimeout, then this method will return immediately if the queue is full. Setting the timeout to kArInfiniteTimeout will cause the thread to wait forever for a chance to send. |
kArSuccess | |
kArQueueFullError |