From 074a7157b6bd3867b60d04f685cdede6063e6e3c Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Wed, 7 May 2025 15:43:01 +0200 Subject: 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 --- src/threading.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/threading.hpp') 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 @@ #pragma once #include "platform.h" +#include "unique.hpp" #define THREADAPI_WINDOWS 1 #define THREADAPI_PTHREAD 2 @@ -73,8 +74,15 @@ static constexpr int kThreadPrioMax{ +3 }; // ################################################################################################# // ################################################################################################# +DECLARE_UNIQUE_TYPE(SudoFlag, bool); +DECLARE_UNIQUE_TYPE(NativePrioFlag, bool); + +std::pair THREAD_NATIVE_PRIOS(); + void THREAD_SETNAME(std::string_view const& name_); -void THREAD_SET_PRIORITY(int prio_, bool sudo_); -void THREAD_SET_AFFINITY(unsigned int aff_); -void THREAD_SET_PRIORITY(std::thread& thread_, int prio_, bool sudo_); +void THREAD_SET_PRIORITY(lua_State* L_, int prio_, NativePrioFlag native_, SudoFlag sudo_); + +void THREAD_SET_AFFINITY(lua_State* L_, unsigned int aff_); + +void THREAD_SET_PRIORITY(lua_State* L_, std::thread& thread_, int prio_, NativePrioFlag native_, SudoFlag sudo_); -- cgit v1.2.3-55-g6feb