aboutsummaryrefslogtreecommitdiff
path: root/src/threading.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/threading.h24
1 files changed, 5 insertions, 19 deletions
diff --git a/src/threading.h b/src/threading.h
index c443c82..f38b2de 100644
--- a/src/threading.h
+++ b/src/threading.h
@@ -58,33 +58,19 @@ static constexpr int THREAD_PRIO_MAX{ +3 };
58#endif // PLATFORM_WIN32 58#endif // PLATFORM_WIN32
59#include <pthread.h> 59#include <pthread.h>
60 60
61// Yield is non-portable: 61#if defined(PLATFORM_LINUX) && !defined(LINUX_SCHED_RR)
62//
63// OS X 10.4.8/9 has pthread_yield_np()
64// Linux 2.4 has pthread_yield() if _GNU_SOURCE is #defined
65// FreeBSD 6.2 has pthread_yield()
66// ...
67//
68
69#if defined(PLATFORM_LINUX)
70extern volatile bool sudo;
71# ifdef LINUX_SCHED_RR
72# define THREAD_PRIO_MIN (sudo ? -3 : 0)
73# else
74static constexpr int THREAD_PRIO_MIN{ 0 }; 62static constexpr int THREAD_PRIO_MIN{ 0 };
75#endif
76# define THREAD_PRIO_MAX (sudo ? +3 : 0)
77#else 63#else
78static constexpr int THREAD_PRIO_MIN{ -3 }; 64static constexpr int THREAD_PRIO_MIN{ -3 };
79static constexpr int THREAD_PRIO_MAX{ +3 };
80#endif 65#endif
66static constexpr int THREAD_PRIO_MAX{ +3 };
81 67
82#endif // THREADAPI == THREADAPI_WINDOWS 68#endif // THREADAPI == THREADAPI_PTHREAD
83// ################################################################################################## 69// ##################################################################################################
84// ################################################################################################## 70// ##################################################################################################
85 71
86void THREAD_SETNAME(char const* _name); 72void THREAD_SETNAME(char const* _name);
87void THREAD_SET_PRIORITY(int prio); 73void THREAD_SET_PRIORITY(int prio_, bool sudo_);
88void THREAD_SET_AFFINITY(unsigned int aff); 74void THREAD_SET_AFFINITY(unsigned int aff);
89 75
90void JTHREAD_SET_PRIORITY(std::jthread& thread_, int prio_); 76void JTHREAD_SET_PRIORITY(std::jthread& thread_, int prio_, bool sudo_);