osgearth
osgearth copied to clipboard
Rework Threading internal queue
This commit rework Threading internal queue
- It replaces the vector + partial sorting with a std::priority_queue
- In introduces a proper abstraction for the internal queue of job
SynchronizedPriorityQueuedJob. By doing so,
- it removes a datarace that was happening on _done
- it ensures that the variables used in the condition_variable are always modified while holding the lock, preventing improper use of block with predicate (as there is small window between the predicate call and the lock which cam lead to lost notifications)
- It refactors the code with this new SynchronizedPriorityQueuedJob.
I've
- rebased the PR, fixed the compilation issue
- made shutdownAll publc and remove its registration with atexit
- changed startThreads to make the thread creation much less dependent on the actual thread scheduling.