Argon RTOS  1.3.0
Tiny embedded real-time kernel
+ Collaboration diagram for Queues:

Description

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...
 

Function Documentation

◆ ar_queue_create()

ar_status_t ar_queue_create ( ar_queue_t *  queue,
const char *  name,
void *  storage,
unsigned  elementSize,
unsigned  capacity 
)

Create a new queue.

Parameters
queueThe storage for the new queue object.
nameThe new queue's name.
storagePointer to a buffer used to store queue elements. The buffer must be at least elementSize * capacity bytes big.
elementSizeSize in bytes of each element in the queue.
capacityThe number of elements that the buffer pointed to by storage will hold.
Return values
kArSuccessThe queue was initialised.

◆ ar_queue_delete()

ar_status_t ar_queue_delete ( ar_queue_t *  queue)

Delete an existing queue.

Parameters
queueThe queue object.

◆ ar_queue_get_count()

uint32_t ar_queue_get_count ( ar_queue_t *  queue)

Returns the current number of elements in the queue.

Parameters
queueThe queue object.
Returns
The number of data elements available in the queue.

◆ ar_queue_get_name()

const char* ar_queue_get_name ( ar_queue_t *  queue)

Get the queue's name.

Parameters
queueThe queue object.
Returns
Pointer to the queue's name.

◆ ar_queue_is_empty()

bool ar_queue_is_empty ( ar_queue_t *  queue)

Returns whether the queue is currently empty.

Parameters
queueThe queue object.
Returns
Boolean indicating whether the given queue is currently empty.

◆ ar_queue_receive()

ar_status_t ar_queue_receive ( ar_queue_t *  queue,
void *  element,
uint32_t  timeout 
)

Remove an item from the queue.

Parameters
queueThe queue object.
[out]element
timeoutThe 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.
Return values
kArSuccess
kArQueueEmptyError

◆ ar_queue_send()

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.

Parameters
queueThe queue object.
elementPointer to the element to post to the queue. The element size was specified in the init() call.
timeoutThe 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.
Return values
kArSuccess
kArQueueFullError