FreeRTOS C-Addons
1.1.0
C-Addon functionality to FreeRTOS
|
#include <stdlib.h>
#include "FreeRTOS.h"
#include "task.h"
#include "workqueue.h"
#include "queue_simple.h"
Go to the source code of this file.
Data Structures | |
struct | pvtWorkItem_t_ |
struct | pvtWorkQueue_t_ |
Typedefs | |
typedef struct pvtWorkItem_t_ | pvtWorkItem_t |
typedef struct pvtWorkQueue_t_ | pvtWorkQueue_t |
Functions | |
static void | WorkerThread (void *parameters) |
WorkQueue_t | CreateWorkQueueEx (const char *const Name, uint16_t StackSize, UBaseType_t Priority) |
void | DestroyWorkQueue (WorkQueue_t wq) |
int | QueueWorkItem (WorkQueue_t wq, WorkItem_t Function, void *UserData) |
typedef struct pvtWorkItem_t_ pvtWorkItem_t |
Work Item, what we actually use internally.
typedef struct pvtWorkQueue_t_ pvtWorkQueue_t |
The internal WorkQueue data structure.
WorkQueue_t CreateWorkQueueEx | ( | const char *const | Name, |
uint16_t | StackSize, | ||
UBaseType_t | Priority | ||
) |
Create a WorkQueue, specifying all options.
Name | The name of the worker thread. |
StackSize | The size of the worker thread stack, in words. |
Priority | The priority of the worker thread. |
Definition at line 255 of file workqueue.c.
void DestroyWorkQueue | ( | WorkQueue_t | WorkQueue | ) |
Destroy a WorkQueue, if allowed.
WorkQueue | The work queue. |
Lock
Flag we are all done.
Signal the Worker thead.
Unlock
Definition at line 312 of file workqueue.c.
int QueueWorkItem | ( | WorkQueue_t | WorkQueue, |
WorkItem_t | WorkItem, | ||
void * | UserData | ||
) |
Add an item of work onto the queue.
WorkQueue | The work queue. |
WorkItem | The function you want called. |
UserData | A value passed back to you. |
Lock the queue
Put the work item on the queue.
Wake the Worker thread up.
Unlock the queue
Definition at line 344 of file workqueue.c.
|
static |
Wait to be woken.
Lock the queue
Keep looping until the work items are all done.
Dequeue an item.
Unlock the queue, the lock is really only for the Queue struct.
Recover the actual work item pointer.
And call the function.
All done, free it.
Lock the queue again so we can check if the Queue is empty yet.
Are we being asked to exit? We want to do this while holding the lock.
Unlock now
If we need to exit, then jump out of the task loop.
Thread cleanup here.
Lock this work queue.
Drain the queue and free everything.
Dequeue the node
Recover the work item from the node.
And free it.
Finally unlock
Free the semaphores
We need to save a local copy of our handle.
And free the work queue stat structure itself.
Finally delete ourselves, we won't go past this call.
Definition at line 101 of file workqueue.c.