forked from OSchip/llvm-project
[clangd] Add thread priority lowering for MacOS as well
Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58492 llvm-svn: 354765
This commit is contained in:
parent
49b6f81a74
commit
f47177ddb4
|
@ -7,6 +7,8 @@
|
|||
#include <thread>
|
||||
#ifdef __USE_POSIX
|
||||
#include <pthread.h>
|
||||
#elif defined(__APPLE__)
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
namespace clang {
|
||||
|
@ -121,6 +123,12 @@ void setCurrentThreadPriority(ThreadPriority Priority) {
|
|||
Priority == ThreadPriority::Low && !AvoidThreadStarvation ? SCHED_IDLE
|
||||
: SCHED_OTHER,
|
||||
&priority);
|
||||
#elif defined(__APPLE__)
|
||||
// https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpriority.2.html
|
||||
setpriority(PRIO_DARWIN_THREAD, 0,
|
||||
Priority == ThreadPriority::Low && !AvoidThreadStarvation
|
||||
? PRIO_DARWIN_BG
|
||||
: 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue