Open hmelder opened 2 months ago
We can probably move all platform-dependent thread prioritisation logic into a new function like _dispatch_set_priority()
(analog to _dispatch_get_priority()
). This function sets the TSD slot __TSD_THREAD_QOS_CLASS
on Darwin, setpriority
on Linux, and SetThreadPriority
on Windows.
@compnerd @lxbndr would be great to get your thoughts on this. 🙏
This PR implements basic thread prioritisation on Linux and Windows and fixes a bug in
dispatch_get_global_queue
where the wrong QOS type is used.Note that this only sets the initial thread priority by translating QoS to thread priorities. Relative priorities are ignored for now. Later QoS overrides and other priority adjustments have no effect.
See the comments for implementation details.
Result on Windows
Result on Linux