Is there a way to set thread priority in Glib v2.32 +?

The Glib 2.30 API allows you to set thread priority through the GThreadPriority enumeration. However, this API is deprecated from 2.32 , and I cannot find information on setting thread priorities using the new API. I Ctrl + F'd through all the thread-related sections in the API refrence and did not find anything priority. Google also seems to know nothing.

So, prioritizes the thread possible in API 2.32? If so, how to do it during creation and is it possible to change it after creating the stream? I know that pthread supports all of this, but I'd rather stick with the platform-independent Glib API.

+4
source share
1 answer

Prioritization of threads has disappeared. In glib git log, this commit explains why

GThread: ignore thread priorities

Thread priorities have already been documented as broken in Solaris, and they make no sense in Linux unless the process separately requests real-time scheduling (and even then it only works as root).

Perhaps using threadpool and g_thread_pool_set_sort_function () might be okay?

+4
source

Source: https://habr.com/ru/post/1433070/


All Articles