aboutsummaryrefslogtreecommitdiff
path: root/src/threading.hpp
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2025-05-07 15:43:01 +0200
committerBenoit Germain <bnt.germain@gmail.com>2025-05-07 15:43:01 +0200
commit074a7157b6bd3867b60d04f685cdede6063e6e3c (patch)
tree21f58c5c739fadaaa57b214e468524efbbe26cbb /src/threading.hpp
parentd0dd3b644b36bac119aa9e9da40c3cfe38a6e234 (diff)
downloadlanes-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.hpp14
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
77DECLARE_UNIQUE_TYPE(SudoFlag, bool);
78DECLARE_UNIQUE_TYPE(NativePrioFlag, bool);
79
80std::pair<int, int> THREAD_NATIVE_PRIOS();
81
76void THREAD_SETNAME(std::string_view const& name_); 82void THREAD_SETNAME(std::string_view const& name_);
77void THREAD_SET_PRIORITY(int prio_, bool sudo_);
78void THREAD_SET_AFFINITY(unsigned int aff_);
79 83
80void THREAD_SET_PRIORITY(std::thread& thread_, int prio_, bool sudo_); 84void THREAD_SET_PRIORITY(lua_State* L_, int prio_, NativePrioFlag native_, SudoFlag sudo_);
85
86void THREAD_SET_AFFINITY(lua_State* L_, unsigned int aff_);
87
88void THREAD_SET_PRIORITY(lua_State* L_, std::thread& thread_, int prio_, NativePrioFlag native_, SudoFlag sudo_);