[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:
Kadir Cetinkaya 2019-02-25 09:19:26 +00:00
parent 49b6f81a74
commit f47177ddb4
1 changed files with 8 additions and 0 deletions

View File

@ -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
}