A linked-list FIFO for passing pointers to user-defined structures between tasks.
More...
Inherits OS_TASK_DLY_OBJ.
|
| | OS_FIFO () |
| | Construct and initialize the FIFO (empty linked list).
|
| |
| uint8_t | Init () |
| | Reset the FIFO to its initial (empty) state.
|
| |
| uint8_t | Post (OS_FIFO_EL *pToPost) |
| | Post an element to the tail of the FIFO.
|
| |
| uint8_t | PostFirst (OS_FIFO_EL *pToPost) |
| | Post an element to the head of the FIFO (priority insertion).
|
| |
| OS_FIFO_EL * | Pend (uint32_t timeoutTicks, uint8_t &result) |
| | Wait for an element to be posted to the FIFO.
|
| |
| OS_FIFO_EL * | Pend (TickTimeout &t, uint8_t &result) |
| | Wait for an element to be posted to the FIFO, using a TickTimeout.
|
| |
| OS_FIFO_EL * | Pend (uint32_t timeoutTicks=WAIT_FOREVER) |
| | Wait for an element to be posted to the FIFO (no result code).
|
| |
| OS_FIFO_EL * | PendUntil (uint32_t timeoutTime, uint8_t &result) |
| | Wait until an absolute TimeTick value for an element to be posted.
|
| |
| OS_FIFO_EL * | PendNoWait (uint8_t &result) |
| | Retrieve an element from the FIFO without waiting.
|
| |
| OS_FIFO_EL * | PendNoWait () |
| | Retrieve an element from the FIFO without waiting (no result code).
|
| |
A linked-list FIFO for passing pointers to user-defined structures between tasks.
Unlike OS_Q (which stores void pointers in a fixed-size array), OS_FIFO uses a linked list so there is no predefined capacity limit. Each element posted must begin with an OS_FIFO_EL-compatible header (a pointer used internally to link elements together). Your application is responsible for allocating the elements, either statically or from the heap.
Elements are extracted in FIFO order (first posted = first retrieved), unless PostFirst() is used to insert at the head.
- Note
- If you only need to pass simple pointer-sized values, OS_Q may be simpler.
- See also
- OS_Q, OS_FIFO_EL, TEMPL_FIFO
Expand for Example Usage
Examples
- Pass a Structure Between Tasks
struct MyMessage
{
int data;
};
MyMessage gMsg;
void ProducerTask(void *pd)
{
gMsg.data = 42;
}
void ConsumerTask(void *pd)
{
if (pEl != NULL)
{
MyMessage *pMsg = (MyMessage *)pEl;
iprintf("Received data: %d\r\n", pMsg->data);
}
}
#define TICKS_PER_SECOND
System clock ticks per second.
Definition constants.h:49
A linked-list FIFO for passing pointers to user-defined structures between tasks.
Definition nbrtos.h:1177
OS_FIFO_EL * Pend(uint32_t timeoutTicks, uint8_t &result)
Wait for an element to be posted to the FIFO.
Definition nbrtos.h:1234
uint8_t Post(OS_FIFO_EL *pToPost)
Post an element to the tail of the FIFO.
Element header for OS_FIFO linked-list entries.
Definition nbrtos.h:1111