Queue

RTOS queue functions. More...

Functions

gos_result_t gos_rtos_queue_init (gos_queue_t *queue, uint32_t message_size, uint32_t number_of_messages)
 Initializes a queue. More...
 
gos_result_t gos_rtos_queue_deinit (gos_queue_t *queue)
 De-initialise a queue. More...
 
gos_result_t gos_rtos_queue_push (gos_queue_t *queue, const void *message, uint32_t timeout_ms)
 Push an object onto the back of a queue. More...
 
gos_result_t gos_rtos_queue_push_to_front (gos_queue_t *queue, const void *message, uint32_t timeout_ms)
 Push an object onto the front of a queue. More...
 
gos_result_t gos_rtos_queue_pop (gos_queue_t *queue, void *message, uint32_t timeout_ms)
 Pops an object off a queue. More...
 
gos_result_t gos_rtos_queue_flush (gos_queue_t *queue)
 Remove all objects from the queue. More...
 
gos_result_t gos_rtos_queue_get_count (gos_queue_t *queue, uint32_t *count_ptr)
 Get number of elements in queue. More...
 
gos_result_t gos_rtos_queue_is_empty (gos_queue_t *queue)
 Check if a queue is empty. More...
 
gos_result_t gos_rtos_queue_is_full (gos_queue_t *queue)
 Check if a queue is full. More...
 

Detailed Description

RTOS queue functions.

Function Documentation

◆ gos_rtos_queue_deinit()

gos_result_t gos_rtos_queue_deinit ( gos_queue_t *  queue)

De-initialise a queue.

Deletes a queue created with gos_rtos_queue_init()

Parameters
[in]queue: Pointer to the queue handle
Returns
Result of API call, gos_result_t

◆ gos_rtos_queue_flush()

gos_result_t gos_rtos_queue_flush ( gos_queue_t *  queue)

Remove all objects from the queue.

This clears all message from the queue.

Parameters
[in]queue: Pointer to the queue handle
Returns
Result of API call, gos_result_t

◆ gos_rtos_queue_get_count()

gos_result_t gos_rtos_queue_get_count ( gos_queue_t *  queue,
uint32_t *  count_ptr 
)

Get number of elements in queue.

Return the number of messages currently in the queue.

Parameters
[in]queue: Pointer to the queue handle
[out]count_ptr: Pointer to hold number of message in queue
Returns
Result of API call, gos_result_t

◆ gos_rtos_queue_init()

gos_result_t gos_rtos_queue_init ( gos_queue_t *  queue,
uint32_t  message_size,
uint32_t  number_of_messages 
)

Initializes a queue.

Initialises a FIFO queue

Parameters
[in]queue: Pointer to the queue handle to be initialised
[in]message_size: Size in bytes of objects that will be held in the queue
[in]number_of_messages: Depth of the queue - i.e. max number of objects in the queue
Returns
Result of API call, gos_result_t

◆ gos_rtos_queue_is_empty()

gos_result_t gos_rtos_queue_is_empty ( gos_queue_t *  queue)

Check if a queue is empty.

This returns GOS_SUCCESS if the queue is empty. It returns GOS_ERROR if the queue is NOT empty.

Parameters
[in]queue: Pointer to the queue handle
Returns
Result of API call, gos_result_t

◆ gos_rtos_queue_is_full()

gos_result_t gos_rtos_queue_is_full ( gos_queue_t *  queue)

Check if a queue is full.

This returns GOS_SUCCESS if the queue is full. It returns GOS_ERROR if the queue is NOT full.

Parameters
[in]queue: Pointer to the queue handle
Returns
Result of API call, gos_result_t

◆ gos_rtos_queue_pop()

gos_result_t gos_rtos_queue_pop ( gos_queue_t *  queue,
void *  message,
uint32_t  timeout_ms 
)

Pops an object off a queue.

This removes an object from the front of the queue. i.e. The oldest object in the queue is removed.

If the queue is empty, this will block until an object is added to the queue OR the specified timeout_ms is exceeded.

Parameters
[in]queue: Pointer to the queue handle
[out]message: Pointer to a buffer that will receive the object being popped off the queue. Size is assumed to be the size specified in gos_rtos_queue_init() , hence you must ensure the buffer is long enough or memory corruption will result
[in]timeout_msNumber of milliseconds to wait before returning
Returns
Result of API call, gos_result_t

◆ gos_rtos_queue_push()

gos_result_t gos_rtos_queue_push ( gos_queue_t *  queue,
const void *  message,
uint32_t  timeout_ms 
)

Push an object onto the back of a queue.

Pushes an object to the back of a queue. This pushed object will be the last to be removed with gos_rtos_queue_pop()

If the queue is full, this API will block until room is available in the queue OR the specified timeout_ms is exceeded.

Parameters
[in]queue: Pointer to the queue handle
[in]message: Object to be added to the queue. Size is assumed to be the size specified in gos_rtos_queue_init()
[in]timeout_ms: Number of milliseconds to wait before returning
Returns
Result of API call, gos_result_t

◆ gos_rtos_queue_push_to_front()

gos_result_t gos_rtos_queue_push_to_front ( gos_queue_t *  queue,
const void *  message,
uint32_t  timeout_ms 
)

Push an object onto the front of a queue.

Pushes an object to the front of a queue. This pushed object will be the first to be removed with gos_rtos_queue_pop()

If the queue is full, this API will block until room is available in the queue OR the specified timeout_ms is exceeded.

Parameters
[in]queue: Pointer to the queue handle
[in]message: Object to be added to the queue. Size is assumed to be the size specified in gos_rtos_queue_init()
[in]timeout_ms: Number of milliseconds to wait before returning
Returns
Result of API call, gos_result_t