File syn_workqueue.h¶
FileList > sched > syn_workqueue.h
Go to the source code of this file
Deferred work queue — ISR-safe function dispatch. More...
#include "../util/syn_spsc_queue.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_WorkItem |
| struct | SYN_WorkQueue |
Public Types¶
| Type | Name |
|---|---|
| typedef void(* | SYN_WorkFunc |
Public Functions¶
| Type | Name |
|---|---|
| void | syn_workqueue_init (SYN_WorkQueue * wq, SYN_WorkItem * buf, size_t capacity) Initialize the work queue. |
| bool | syn_workqueue_post (SYN_WorkQueue * wq, SYN_WorkFunc func, void * ctx) Post a work item. ISR-safe (single producer). |
| size_t | syn_workqueue_process (SYN_WorkQueue * wq) Process all pending work items. |
Public Static Functions¶
| Type | Name |
|---|---|
| bool | syn_workqueue_empty (const SYN_WorkQueue * wq) Check if the queue is empty. |
| uint32_t | syn_workqueue_overflows (const SYN_WorkQueue * wq) Get overflow count (posts dropped). |
| size_t | syn_workqueue_pending (const SYN_WorkQueue * wq) Get the number of pending items. |
Detailed Description¶
ISRs push work items (function + context) into a lock-free ring. The main loop drains the queue by calling syn_workqueue_process().
** **
SYN_WorkItem items[8];
SYN_WorkQueue wq;
syn_workqueue_init(&wq, items, 8);
// In ISR:
syn_workqueue_post(&wq, my_handler, my_data);
// In main loop:
syn_workqueue_process(&wq);
Public Types Documentation¶
typedef SYN_WorkFunc¶
Work function signature.
Public Functions Documentation¶
function syn_workqueue_init¶
Initialize the work queue.
Parameters:
wqPointer to work queue context to initialize.bufBacking storage array for work items.capacityNumber of elements in the buffer.
function syn_workqueue_post¶
Post a work item. ISR-safe (single producer).
Parameters:
wqPointer to work queue context.funcCallback function to defer.ctxUser data passed to the callback.
Returns:
true if posted, false if queue is full.
function syn_workqueue_process¶
Process all pending work items.
Call from main loop. Executes each queued function in FIFO order.
Parameters:
wqPointer to work queue context.
Returns:
Number of items processed.
Public Static Functions Documentation¶
function syn_workqueue_empty¶
Check if the queue is empty.
Parameters:
wqPointer to work queue context.
Returns:
true if empty.
function syn_workqueue_overflows¶
Get overflow count (posts dropped).
Parameters:
wqPointer to work queue context.
Returns:
Count of dropped posts.
function syn_workqueue_pending¶
Get the number of pending items.
Parameters:
wqPointer to work queue context.
Returns:
Number of pending items.
The documentation for this class was generated from the following file src/syntropic/sched/syn_workqueue.h