osgearth icon indicating copy to clipboard operation
osgearth copied to clipboard

Rework Threading internal queue

Open Davidbrcz opened this issue 3 years ago • 1 comments

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.

Davidbrcz avatar Nov 05 '21 15:11 Davidbrcz

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.

Davidbrcz avatar Dec 10 '21 16:12 Davidbrcz