ttypt/stl_job.h(3)stele

NAME

ttypt/stl_job.h - Generic message-passing multi-core compute worker pool for libstele.

SYNOPSIS

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

Typedefs

typedef int32_t(* stl_job_exec_fn) (uint32_t kind, const void *in_buf, uint32_t in_len, void *out_buf, uint32_t out_cap)

Pure deterministic compute entry point for a job.

Functions

STL_JOB_API int stl_job_init (const char *worker_url, unsigned int max_workers, stl_job_exec_fn native_exec)

Initialize the global compute worker pool.

STL_JOB_API unsigned int stl_job_worker_count (void)

Query the number of active background compute workers (0 = cooperative).

STL_JOB_API stl_job_id_t stl_job_submit (uint32_t kind, const void *in_buf, uint32_t in_len, uint32_t out_cap)

Submit an asynchronous compute job.

STL_JOB_API stl_job_status_t stl_job_poll (stl_job_id_t id)

Non-blocking status check for a submitted job.

STL_JOB_API int32_t stl_job_take (stl_job_id_t id, void *dst, uint32_t dst_cap)

Retrieve the output of a completed job and release its slot.

STL_JOB_API unsigned int stl_job_step (unsigned int max_jobs)

Cooperatively execute up to max_jobs queued jobs on the caller thread.

STL_JOB_API void stl_job_shutdown (void)

Drain background workers, free all pending/unclaimed job slots, and reset the pool so stl_job_init() may be called again.

Detailed Description

Generic message-passing multi-core compute worker pool for libstele.

Dispatches pure deterministic compute jobs (kind, in_buf) -> out_buf off the caller thread without requiring SharedArrayBuffer:

Typedef Documentation

typedef int32_t(* stl_job_exec_fn) (uint32_t kind, const void *in_buf, uint32_t in_len, void *out_buf, uint32_t out_cap)

Pure deterministic compute entry point for a job. Writes at most out_cap bytes into out_buf and returns the byte count written (>= 0), or a negative value on error.

Function Documentation

STL_JOB_API int stl_job_init (const char * worker_url, unsigned int max_workers, stl_job_exec_fn native_exec)

Initialize the global compute worker pool. Idempotent if already initialized.

Returns 0 on success, -1 on error.

STL_JOB_API unsigned int stl_job_step (unsigned int max_jobs)

Cooperatively execute up to max_jobs queued jobs on the caller thread. No-op (returns 0) when background workers are active. Used to guarantee bounded per-frame forward progress when stl_job_worker_count() == 0.

STL_JOB_API stl_job_id_t stl_job_submit (uint32_t kind, const void * in_buf, uint32_t in_len, uint32_t out_cap)

Submit an asynchronous compute job. Copies in_len bytes from in_buf (if non-NULL) and reserves out_cap bytes for the result. Returns a non-zero stl_job_id_t on success, or 0 if the pool is uninitialized or saturated.

STL_JOB_API int32_t stl_job_take (stl_job_id_t id, void * dst, uint32_t dst_cap)

Retrieve the output of a completed job and release its slot.

Author

Generated automatically by Doxygen for stele from the source code.