Skip to content

Commit c6a1d49

Browse files
committed
Merging r354765:
------------------------------------------------------------------------ r354765 | kadircet | 2019-02-25 10:19:26 +0100 (Mon, 25 Feb 2019) | 9 lines [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: 354983
1 parent 3043a72 commit c6a1d49

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clang-tools-extra/clangd/Threading.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <thread>
88
#ifdef __USE_POSIX
99
#include <pthread.h>
10+
#elif defined(__APPLE__)
11+
#include <sys/resource.h>
1012
#endif
1113

1214
namespace clang {
@@ -121,6 +123,12 @@ void setCurrentThreadPriority(ThreadPriority Priority) {
121123
Priority == ThreadPriority::Low && !AvoidThreadStarvation ? SCHED_IDLE
122124
: SCHED_OTHER,
123125
&priority);
126+
#elif defined(__APPLE__)
127+
// https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpriority.2.html
128+
setpriority(PRIO_DARWIN_THREAD, 0,
129+
Priority == ThreadPriority::Low && !AvoidThreadStarvation
130+
? PRIO_DARWIN_BG
131+
: 0);
124132
#endif
125133
}
126134

0 commit comments

Comments
 (0)