ttypt/wq.h(3)stele

NAME

ttypt/wq.h - Cross-platform lock-free workqueue & worker pool for libstele.

SYNOPSIS

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdatomic.h>
#include 'iso.h'

Data Structures

struct stl_wq_task

Embeddable zero-allocation workqueue task descriptor.

Typedefs

typedef void(* stl_wq_fn) (void *arg)

Task callback signature executed by a workqueue worker or cooperative step.

typedef struct stl_wq_task stl_wq_task_t

Embeddable zero-allocation workqueue task descriptor.

Enumerations

enum stl_wq_state_t

Lifecycle states for a stl_wq_task_t.

Functions

ISO_EXPORT (unsigned int, stl_cpu_count, void)

Query the number of hardware logical processors available. Returns >= 1 on all platforms.

ISO_EXPORT (stl_wq_t *, stl_wq_create, const char *name, unsigned int nthreads, unsigned int ring_cap)

Create a named workqueue with nthreads persistent worker threads and a power-of-two ring buffer of capacity ring_cap (default 256 if 0).

ISO_EXPORT (int, stl_wq_submit, stl_wq_t *wq, stl_wq_task_t *task, stl_wq_fn fn, void *arg)

Submit a task to the workqueue.

ISO_EXPORT (unsigned int, stl_wq_step, stl_wq_t *wq, unsigned int max_tasks)

Execute up to max_tasks pending tasks from wq on the calling thread. Returns the number of tasks executed.

ISO_EXPORT (void, stl_wq_wait, stl_wq_t *wq, stl_wq_task_t *task)

Wait until a specific task has completed (STL_WQ_DONE or STL_WQ_IDLE). Cooperatively helps drain the queue while waiting so the caller never deadlocks.

ISO_EXPORT (void, stl_wq_drain, stl_wq_t *wq)

Wait until all queued and running tasks in wq have completed.

unsigned int stl_wq_thread_count (const stl_wq_t *wq)

Query the number of active worker threads backing wq (0 = cooperative single-threaded).

ISO_EXPORT (void, stl_wq_destroy, stl_wq_t *wq)

Drain all pending work, stop worker threads, and free wq.

Detailed Description

Cross-platform lock-free workqueue & worker pool for libstele.

Provides a unified, zero-allocation-per-job taskqueue (stl_wq_t) that maps transparently to:

Typedef Documentation

typedef struct stl_wq_task stl_wq_task_t

Embeddable zero-allocation workqueue task descriptor. Embed directly inside your struct (e.g. ar_node_meta_t or block_bb_cache_slot_t) so submitting jobs requires zero malloc/free calls.

Function Documentation

ISO_EXPORT (int , stl_wq_submit , stl_wq_t * wq, stl_wq_task_t * task, stl_wq_fn fn, void * arg)

Submit a task to the workqueue.

ISO_EXPORT (stl_wq_t * , stl_wq_create , const char * name, unsigned int nthreads, unsigned int ring_cap)

Create a named workqueue with nthreads persistent worker threads and a power-of-two ring buffer of capacity ring_cap (default 256 if 0). If nthreads == 0, automatically selects a balanced worker count (clamp(stl_cpu_count() - 1, 1, 4) on native, or cooperative / host-backed on WASM).

Author

Generated automatically by Doxygen for stele from the source code.