diff options
| author | Kadir Cetinkaya <kadircet@google.com> | 2019-04-16 14:32:43 +0000 |
|---|---|---|
| committer | Kadir Cetinkaya <kadircet@google.com> | 2019-04-16 14:32:43 +0000 |
| commit | 8fdc5abffe2eec8bf08b6e1bda536e52fca4cae8 (patch) | |
| tree | 3b437f5daab224ef88527292190e6680fc53aed1 /llvm/lib/Support/Windows/Threading.inc | |
| parent | 3e8124631eee81b8915651969df2ff5364b6284a (diff) | |
| download | bcm5719-llvm-8fdc5abffe2eec8bf08b6e1bda536e52fca4cae8.tar.gz bcm5719-llvm-8fdc5abffe2eec8bf08b6e1bda536e52fca4cae8.zip | |
[llvm][Support] Provide interface to set thread priorities
Summary:
We have a multi-platform thread priority setting function(last piece
landed with D58683), I wanted to make this available to all llvm community,
there seem to be other users of such functionality with portability fixmes:
lib/Support/CrashRecoveryContext.cpp
tools/clang/tools/libclang/CIndex.cpp
Reviewers: gribozavr, ioeric
Subscribers: krytarowski, jfb, kristina, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59130
llvm-svn: 358494
Diffstat (limited to 'llvm/lib/Support/Windows/Threading.inc')
| -rw-r--r-- | llvm/lib/Support/Windows/Threading.inc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc index c53624c0dc9..96649472cc9 100644 --- a/llvm/lib/Support/Windows/Threading.inc +++ b/llvm/lib/Support/Windows/Threading.inc @@ -106,3 +106,19 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) { // value. Name.clear(); } + +SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) { + // https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-setthreadpriority + // Begin background processing mode. The system lowers the resource scheduling + // priorities of the thread so that it can perform background work without + // significantly affecting activity in the foreground. + // End background processing mode. The system restores the resource scheduling + // priorities of the thread as they were before the thread entered background + // processing mode. + return SetThreadPriority(GetCurrentThread(), + Priority == ThreadPriority::Background + ? THREAD_MODE_BACKGROUND_BEGIN + : THREAD_MODE_BACKGROUND_END) + ? SetThreadPriorityResult::SUCCESS + : SetThreadPriorityResult::FAILURE; +} |

