linux – 有没有办法在Glib v2.32中设置线程优先级?
作者:互联网
Glib 2.30 API允许通过GThreadPriority枚举设置线程优先级.但是,该API是deprecated as of 2.32,我找不到任何有关使用新API设置线程优先级的信息.我已经通过API refrence中所有与线程相关的部分按Ctrl键找到了与优先级无关的部分.谷歌似乎也不知道任何事情.
那么在2.32 API中为可能的线程分配优先级呢?如果是,如何在创建时执行此操作,是否可以在创建线程后更改它?我知道pthread支持所有这些,但我更喜欢坚持与平台无关的Glib API.
解决方法:
设置线程优先级已经消失.在glib git log this commit解释了原因
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).
也许使用线程池,g_thread_pool_set_sort_function ()
可能没问题?
标签:linux,multithreading,cross-platform,glib,multiplatform 来源: https://codeday.me/bug/20190626/1288655.html