Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
The purpose of this pull request is to add an extension that implements a simple but flexible job system. This is an extension built on top of the recently introduced threads API. This extension is ready for 1.0 status (API is stable).
Design
The design is relatively simple. Users submit an array of jobs and receive an atomic counter. This counter's initial value is the number of jobs just submitted. Users later can wait on this counter to reach a specified value.
The atomic counters are managed through a free list (protected by the "latch" mentioned below).
A queue of jobs is protected by an atomic "latch". Threads remove jobs from the queue, execute them, then decrement their associated counter. If there are no jobs, the threads sleep on a conditional variable. When new jobs are pushed, threads are woken up using the conditional variable.
API