diff options
| author | Benoit Germain <bnt.germain@gmail.com> | 2025-05-07 15:43:01 +0200 |
|---|---|---|
| committer | Benoit Germain <bnt.germain@gmail.com> | 2025-05-07 15:43:01 +0200 |
| commit | 074a7157b6bd3867b60d04f685cdede6063e6e3c (patch) | |
| tree | 21f58c5c739fadaaa57b214e468524efbbe26cbb /src/threading.hpp | |
| parent | d0dd3b644b36bac119aa9e9da40c3cfe38a6e234 (diff) | |
| download | lanes-074a7157b6bd3867b60d04f685cdede6063e6e3c.tar.gz lanes-074a7157b6bd3867b60d04f685cdede6063e6e3c.tar.bz2 lanes-074a7157b6bd3867b60d04f685cdede6063e6e3c.zip | |
Thread priority rework
* thread priorities can now be set using the native range of values, if desired.
* thread API errors cause a Lua error instead of aborting the program.
* new function lanes.thread_priority_range(), to query the valid range of priorities.
* unit tests for all of the above
Diffstat (limited to 'src/threading.hpp')
| -rw-r--r-- | src/threading.hpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/threading.hpp b/src/threading.hpp index 912c28f..07c1ab3 100644 --- a/src/threading.hpp +++ b/src/threading.hpp | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | 2 | ||
| 3 | #include "platform.h" | 3 | #include "platform.h" |
| 4 | #include "unique.hpp" | ||
| 4 | 5 | ||
| 5 | #define THREADAPI_WINDOWS 1 | 6 | #define THREADAPI_WINDOWS 1 |
| 6 | #define THREADAPI_PTHREAD 2 | 7 | #define THREADAPI_PTHREAD 2 |
| @@ -73,8 +74,15 @@ static constexpr int kThreadPrioMax{ +3 }; | |||
| 73 | // ################################################################################################# | 74 | // ################################################################################################# |
| 74 | // ################################################################################################# | 75 | // ################################################################################################# |
| 75 | 76 | ||
| 77 | DECLARE_UNIQUE_TYPE(SudoFlag, bool); | ||
| 78 | DECLARE_UNIQUE_TYPE(NativePrioFlag, bool); | ||
| 79 | |||
| 80 | std::pair<int, int> THREAD_NATIVE_PRIOS(); | ||
| 81 | |||
| 76 | void THREAD_SETNAME(std::string_view const& name_); | 82 | void THREAD_SETNAME(std::string_view const& name_); |
| 77 | void THREAD_SET_PRIORITY(int prio_, bool sudo_); | ||
| 78 | void THREAD_SET_AFFINITY(unsigned int aff_); | ||
| 79 | 83 | ||
| 80 | void THREAD_SET_PRIORITY(std::thread& thread_, int prio_, bool sudo_); | 84 | void THREAD_SET_PRIORITY(lua_State* L_, int prio_, NativePrioFlag native_, SudoFlag sudo_); |
| 85 | |||
| 86 | void THREAD_SET_AFFINITY(lua_State* L_, unsigned int aff_); | ||
| 87 | |||
| 88 | void THREAD_SET_PRIORITY(lua_State* L_, std::thread& thread_, int prio_, NativePrioFlag native_, SudoFlag sudo_); | ||
