Question

Glib 2.30 API allows setting thread priority via GThreadPriority enum. However, that API is deprecated as of 2.32 and I can't find any info on setting thread priorities using the new API. I've Ctrl+F'd through all thread-related sections in the API refrence and found nothing priority-related. Google also doesn't seem to know anything.

So is assigning priority to a thread possible in the 2.32 API at all? If yes, how to do it on creation and is it possible to change it after the thread is created? I know at that pthread supports all this, but I'd prefer to stick to the platform-independent Glib API.

Was it helpful?

Solution

Setting thread priorities is gone. In the glib git log this commit explains why

GThread: deprecate thread priorities

Thread priorities were already documented as not working on Solaris, and they are meaningless on Linux unless the process separately requests realtime scheduling (and even then, it appears only to work as root).

Maybe using a threadpool and the g_thread_pool_set_sort_function () could be fine ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top