diff options
author | ozaykova <[email protected]> | 2023-02-01 14:06:22 +0300 |
---|---|---|
committer | ozaykova <[email protected]> | 2023-02-01 14:06:22 +0300 |
commit | 99bf72df7c096ea5a2b9015d3bfe4b84fc02c469 (patch) | |
tree | 5817a254542a2619c20ef505b696c25b527a1f7d /util/system/thread.cpp | |
parent | e586e630d0fa60533135bae70fce3613feab9a85 (diff) |
SetLowestThreadPriority in util
Diffstat (limited to 'util/system/thread.cpp')
-rw-r--r-- | util/system/thread.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/util/system/thread.cpp b/util/system/thread.cpp index aa2a4fc9ddc..e9c3da3d113 100644 --- a/util/system/thread.cpp +++ b/util/system/thread.cpp @@ -43,6 +43,21 @@ bool SetHighestThreadPriority() { #endif } +bool SetLowestThreadPriority() { +#ifdef _win_ + return SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST); +#else + struct sched_param sch; + memset(&sch, 0, sizeof(sch)); + sch.sched_priority = 0; + #ifdef _darwin_ + return pthread_setschedparam(pthread_self(), SCHED_RR, &sch) == 0; + #else + return pthread_setschedparam(pthread_self(), SCHED_IDLE, &sch) == 0; + #endif +#endif +} + namespace { using TParams = TThread::TParams; using TId = TThread::TId; |