htils 1
A small set of utilities for C programming.
Loading...
Searching...
No Matches
htils_worker Struct Reference

A reusable worker slot. More...

#include <worker.h>

Data Fields

thrd_t thread
arena_tscratch
atomic_b32 running
atomic_b32 pause
b32 detached
htils_worker_fn_t fn
htils_worker_task_t task
void * userdata
mtx_t pause_mtx
cnd_t pause_cnd
b32 primitives_init

Detailed Description

A reusable worker slot.

Caller-owned, one per concurrent task. Each slot owns one scratch arena, created lazily and cleared at the end of every task. A slot must not be respawned while still running. It runs either a single-shot fn or a sliced task (exactly one is set).

Parameters
threadThe worker thread.
scratchPrivate temp arena; cleared each task, reused on respawn.
runningCleared when the task finishes or is stopped.
pausePauses a sliced task between slices.
detachedWhether the worker is fire-and-forget.
fnThe active single-shot body, or null.
taskThe active sliced body, or null.
userdataThe active task context.
pause_mtxGuards the pause wait.
pause_cndSignalled on resume/stop.
primitives_initWhether the primitives have been initialized.

Field Documentation

◆ detached

b32 htils_worker::detached

◆ fn

htils_worker_fn_t htils_worker::fn

◆ pause

atomic_b32 htils_worker::pause

◆ pause_cnd

cnd_t htils_worker::pause_cnd

◆ pause_mtx

mtx_t htils_worker::pause_mtx

◆ primitives_init

b32 htils_worker::primitives_init

◆ running

atomic_b32 htils_worker::running

◆ scratch

arena_t* htils_worker::scratch

◆ task

htils_worker_task_t htils_worker::task

◆ thread

thrd_t htils_worker::thread

◆ userdata

void* htils_worker::userdata

The documentation for this struct was generated from the following file: