NetBurner 3.5.0
PDF Version |
|
A message queue is an object that enables tasks and interrupt service routines to pend and post pointer sized messages. The pointer values typically point to some type of object or structure that contains the actual message or data. A queue functions as a fixed size First In First Out (FIFO) storage for 32-bit void pointers that can be used for communication between tasks. More...
#include <nbrtos.h>
Inherits OS_TASK_DLY_OBJ.
Public Member Functions | |
OS_Q (void **pQueueStorage, uint8_t size) | |
Create and initialize a queue object. | |
uint8_t | Init (void **pQueueStorage, uint8_t size) |
Set the queue object to its initial state. | |
uint8_t | Post (void *pItem) |
Post a message to the next available location in the queue. | |
uint8_t | PostFirst (void *pItem) |
Post a message to the head of the queue. | |
uint8_t | PostUnique (void *pItem) |
Post the specified message to the next available location in the queue, but only if the message is unique and does not exist anywhere else in the queue. | |
uint8_t | PostUniqueFirst (void *msg) |
Post the specified message to the first location in the queue, but only if the message is unique and does not exist anywhere else in the queue. | |
void * | Pend (uint32_t timeoutTicks, uint8_t &result) |
Wait the specified number of time ticks for some other task to post to the queue. | |
void * | Pend (TickTimeout &t, uint8_t &result) |
Wait the specified number of TickTimeout ticks for some other task to post to the queue. | |
void * | Pend (uint32_t timeoutTicks=WAIT_FOREVER) |
Wait the specified number of time ticks for some other task to post to the queue. | |
void * | PendUntil (uint32_t timeoutTime, uint8_t &result) |
Wait the specified TimeTicks value for some other task to post to the queue. | |
void * | PendNoWait (uint8_t &result) |
Checks if a message is available in the queue and returns immediately. | |
void * | PendNoWait () |
Checks if a message is available in the queue and returns immediately. | |
A message queue is an object that enables tasks and interrupt service routines to pend and post pointer sized messages. The pointer values typically point to some type of object or structure that contains the actual message or data. A queue functions as a fixed size First In First Out (FIFO) storage for 32-bit void pointers that can be used for communication between tasks.
A queue can be thought of as an array of void pointers, unlike a mailbox which can store only one void pointer. Access is controlled so that the queue can be safely utilized by multiple tasks. Tasks write to the queue using a Post function, and read from the queue using a Pend function.
The void pointer can represent anything, such as a pointer to a variable, object, string, or just used as a 32-bit value. How it is used is defined by the tasks that post and pend to it.
|
inline |
Create and initialize a queue object.
The queue storage must be allocated in your application. A pointer to the storage area is then passed to the queue constructor. For example,
pQueueStorage | A pointer to an array of (void *) pointers to hold queue messages. |
size | The number of pointers the queue can store. |
uint8_t OS_Q::Init | ( | void ** | pQueueStorage, |
uint8_t | size ) |
Set the queue object to its initial state.
pQueueStorage | A pointer to an array of (void *) pointers to hold queue messages. |
size | The number of pointers the queue can store. |
void * OS_Q::Pend | ( | TickTimeout & | t, |
uint8_t & | result ) |
Wait the specified number of TickTimeout ticks for some other task to post to the queue.
t | The number of system ticks to wait. A value of 0 will wait forever. |
result | Reference to store the status of the function call, NBRTOS Error Codes. OS_NO_ERR if successful, OS_TIMEOUT if it timed out. |
Message | If successful |
NULL | If it timed out |
|
inline |
Wait the specified number of time ticks for some other task to post to the queue.
timeoutTicks | The number of system ticks to wait. A value of 0 will wait forever. |
result | Reference to store the status of the function call, NBRTOS Error Codes. OS_NO_ERR if successful, OS_TIMEOUT if it timed out. |
Message | If successful |
NULL | If it timed out |
|
inline |
Wait the specified number of time ticks for some other task to post to the queue.
timeoutTicks | The number of system ticks to wait. If no value is specified, it will wait forever. |
Message | If successful |
NULL | If it timed out |
|
inline |
Checks if a message is available in the queue and returns immediately.
Message | If successful |
NULL | If it timed out |
void * OS_Q::PendNoWait | ( | uint8_t & | result | ) |
Checks if a message is available in the queue and returns immediately.
result | Reference to store the status of the function call, NBRTOS Error Codes. OS_NO_ERR if successful, OS_TIMEOUT if it timed out. |
Message | If successful |
NULL | If it timed out |
|
inline |
Wait the specified TimeTicks value for some other task to post to the queue.
timeoutTime | The value of system TimeTicks to wait for |
result | Reference to store the status of the function call, NBRTOS Error Codes. OS_NO_ERR if successful, OS_TIMEOUT if it timed out. |
Message | If successful |
NULL | If it timed out |
uint8_t OS_Q::Post | ( | void * | pItem | ) |
Post a message to the next available location in the queue.
pItem | Message (void pointer) to post |
OS_NO_ERR | If successful |
OS_Q_FULL | If the queue is full, NBRTOS Error Codes |
uint8_t OS_Q::PostFirst | ( | void * | pItem | ) |
Post a message to the head of the queue.
pItem | Message (void pointer) to post |
OS_NO_ERR | If successful |
OS_Q_FULL | If the queue is full, NBRTOS Error Codes |
uint8_t OS_Q::PostUnique | ( | void * | pItem | ) |
Post the specified message to the next available location in the queue, but only if the message is unique and does not exist anywhere else in the queue.
pItem | Message (void pointer) to post |
OS_NO_ERR | If successful |
OS_Q_EXISTS | If the message already exists in the queue NBRTOS Error Codes |
OS_Q_FULL | If the queue is full NBRTOS Error Codes |
uint8_t OS_Q::PostUniqueFirst | ( | void * | msg | ) |
Post the specified message to the first location in the queue, but only if the message is unique and does not exist anywhere else in the queue.
msg | Message (void pointer) to post |
OS_NO_ERR | If successful |
OS_Q_EXISTS | If the message already exists in the queue NBRTOS Error Codes |
OS_Q_FULL | If the queue is full NBRTOS Error Codes |