Job system module


This job system follows thread pool pattern to minimize the costs of thread initialization. It reuses fixed number of threads to process variable number of jobs.


struct zpl_thread_job
struct zpl_thread_worker
struct zpl_thread_pool


using zpl_jobs_proc = void(*)(void*data)


auto zpl_jobs_init(zpl_thread_pool* pool, zpl_allocator a, zpl_u32 max_threads) -> void
Initialize thread pool with specified amount of fixed threads.
auto zpl_jobs_free(zpl_thread_pool* pool) -> void
Release the resources use by thread pool.
auto zpl_jobs_enqueue(zpl_thread_pool* pool, zpl_jobs_proc proc, void* data) -> void
Enqueue a job with specified data.
auto zpl_jobs_enqueue_with_priority(zpl_thread_pool* pool, zpl_jobs_proc proc, void* data, zpl_i32 priority) -> void
Enqueue a job with specific priority with specified data.
auto zpl_jobs_process(zpl_thread_pool* pool) -> zpl_b32
Process all jobs and check all threads. Should be called by Main Thread in a tight loop.