[PATCH] D58492: [clangd] Add thread priority lowering for MacOS as well

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 25 01:21:24 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE354765: [clangd] Add thread priority lowering for MacOS as well (authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58492?vs=187908&id=188106#toc

Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58492/new/

https://reviews.llvm.org/D58492

Files:
  clangd/Threading.cpp


Index: clangd/Threading.cpp
===================================================================
--- clangd/Threading.cpp
+++ clangd/Threading.cpp
@@ -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 @@
       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
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58492.188106.patch
Type: text/x-patch
Size: 838 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190225/8f30799f/attachment.bin>


More information about the cfe-commits mailing list