1#ifndef KEEL_THREAD_POOL_H
2#define KEEL_THREAD_POOL_H
Bring-your-own allocator vtable.
Definition allocator.h:12
Composable event loop context.
Definition event_ctx.h:42
Thread pool configuration. All fields have sensible defaults when set to 0/NULL.
Definition thread_pool.h:30
int queue_capacity
Definition thread_pool.h:32
int num_workers
Definition thread_pool.h:31
KlAllocator * alloc
Definition thread_pool.h:33
Work item — passed by pointer to kl_thread_pool_submit. Copied into the internal queue (caller can st...
Definition thread_pool.h:19
KlWorkDoneFn done_fn
Definition thread_pool.h:21
void * user_data
Definition thread_pool.h:23
KlWorkFn work_fn
Definition thread_pool.h:20
KlWorkCancelFn cancel_fn
Definition thread_pool.h:22
void(* KlWorkCancelFn)(void *user_data)
Cancel function — runs on shutdown if work item never started.
Definition thread_pool.h:13
struct KlThreadPool KlThreadPool
Definition thread_pool.h:36
void(* KlWorkFn)(void *user_data)
Work function — runs on a worker thread.
Definition thread_pool.h:9
int kl_thread_pool_submit(KlThreadPool *pool, const KlWorkItem *item)
Submit work. Copies *item into the internal queue.
void kl_thread_pool_free(KlThreadPool *pool)
Drain queue, join threads, remove watcher, free.
void(* KlWorkDoneFn)(void *user_data)
Done function — runs on the event loop thread after work completes.
Definition thread_pool.h:11
KlThreadPool * kl_thread_pool_create(KlEventCtx *ctx, const KlThreadPoolConfig *cfg)
Create pool, start worker threads, register pipe watcher with ctx.