Luna::JobSystem::allocate_job_id

job_id_t allocate_job_id()

Allocates one job ID, so that other threads can wait for it by calling wait_job.

Return value

Returns the allocated job ID.

Remark

This function is called internally by the job system for all jobs submitted by submit_job, so the user doesn't need to call this function manually. However, the job ID can also be used solely without submitting any job to provide a synchronizing point that other threads can wait for.

Every allocated job ID must be finished by calling finish_job_id, or memory leak will occur. For job IDs created by submit_job, the job system calls finish_job_id automatically when the job callback function returns, so the user should not finish it manually. But for job IDs created by allocate_job_id, the user should call finish_job_id manually to correctly finish them.