Skip to content

File syn_workqueue.c

FileList > sched > syn_workqueue.c

Go to the source code of this file

Deferred work queue implementation.

  • #include "../util/syn_assert.h"
  • #include "syn_workqueue.h"
  • #include <string.h>

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 Functions Documentation

function syn_workqueue_init

Initialize the work queue.

void syn_workqueue_init (
    SYN_WorkQueue * wq,
    SYN_WorkItem * buf,
    size_t capacity
) 

Parameters:

  • wq Pointer to work queue context to initialize.
  • buf Backing storage array for work items.
  • capacity Number of elements in the buffer.

function syn_workqueue_post

Post a work item. ISR-safe (single producer).

bool syn_workqueue_post (
    SYN_WorkQueue * wq,
    SYN_WorkFunc func,
    void * ctx
) 

Parameters:

  • wq Pointer to work queue context.
  • func Callback function to defer.
  • ctx User data passed to the callback.

Returns:

true if posted, false if queue is full.


function syn_workqueue_process

Process all pending work items.

size_t syn_workqueue_process (
    SYN_WorkQueue * wq
) 

Call from main loop. Executes each queued function in FIFO order.

Parameters:

  • wq Pointer to work queue context.

Returns:

Number of items processed.



The documentation for this class was generated from the following file src/syntropic/sched/syn_workqueue.c