diff options
author | ozaykova <ozaykova@yandex-team.com> | 2023-02-01 14:06:22 +0300 |
---|---|---|
committer | ozaykova <ozaykova@yandex-team.com> | 2023-02-01 14:06:22 +0300 |
commit | 99bf72df7c096ea5a2b9015d3bfe4b84fc02c469 (patch) | |
tree | 5817a254542a2619c20ef505b696c25b527a1f7d /util | |
parent | e586e630d0fa60533135bae70fce3613feab9a85 (diff) | |
download | ydb-99bf72df7c096ea5a2b9015d3bfe4b84fc02c469.tar.gz |
SetLowestThreadPriority in util
Diffstat (limited to 'util')
-rw-r--r-- | util/system/thread.cpp | 15 | ||||
-rw-r--r-- | util/system/thread.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/util/system/thread.cpp b/util/system/thread.cpp index aa2a4fc9dd..e9c3da3d11 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; diff --git a/util/system/thread.h b/util/system/thread.h index a6e8abdb5b..830c98a5c3 100644 --- a/util/system/thread.h +++ b/util/system/thread.h @@ -11,6 +11,7 @@ #include "progname.h" bool SetHighestThreadPriority(); +bool SetLowestThreadPriority(); class TThread { template <typename Callable> |