Job System
Job system module provides thread pool to execute jobs asynchronously for a multithreaded computer program.
Alias types
-
Identifies one job that can be waited.
-
using job_func_t = void(void* params)
The callback function of one job.
Constants
-
constexpr job_id_t INVALID_JOB_ID
A special ID that identifies one invalid job.
Functions
-
Allocates one job ID, so that other threads can wait for it by calling wait_job.
-
void finish_job_id(job_id_t job)
Marks one job ID as finished, so that all jobs waiting for this job ID will be resumed. This function should only be called for job IDs allocated by allocate_job_id, never call this function for job IDs returned by submit_job. See remarks of allocate_job_id for details.
-
void * new_job(job_func_t func, usize param_size, usize param_alignment, void parent=nullptr)
Creates a new job.
-
job_id_t submit_job(void *params)
Submits the job to the job system.
-
job_id_t get_current_job_id(void *params)
Fetches the job ID assigned with the specified job.
-
Blocks the current thread to wait for the job to finish.
-
bool is_job_finished(job_id_t job)
Checks whether the specified job is finished.