|
@@ -11,7 +11,6 @@ |
|
|
#if defined ARCH_WIN |
|
|
#if defined ARCH_WIN |
|
|
#include <windows.h> |
|
|
#include <windows.h> |
|
|
#include <shellapi.h> |
|
|
#include <shellapi.h> |
|
|
#include <processthreadsapi.h> |
|
|
|
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -93,18 +92,19 @@ void setThreadName(const std::string &name) { |
|
|
#if defined ARCH_LIN || defined ARCH_MAC |
|
|
#if defined ARCH_LIN || defined ARCH_MAC |
|
|
pthread_setname_np(pthread_self(), name.c_str()); |
|
|
pthread_setname_np(pthread_self(), name.c_str()); |
|
|
#elif defined ARCH_WIN |
|
|
#elif defined ARCH_WIN |
|
|
SetThreadDescription(GetCurrentThread(), name.c_str()); |
|
|
|
|
|
|
|
|
// Unsupported on Windows |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void setThreadRealTime() { |
|
|
void setThreadRealTime() { |
|
|
#if defined ARCH_LIN || defined ARCH_MAC |
|
|
#if defined ARCH_LIN || defined ARCH_MAC |
|
|
|
|
|
// Round-robin scheduler policy |
|
|
int policy = SCHED_RR; |
|
|
int policy = SCHED_RR; |
|
|
struct sched_param param; |
|
|
struct sched_param param; |
|
|
param.sched_priority = sched_get_priority_max(policy); |
|
|
param.sched_priority = sched_get_priority_max(policy); |
|
|
pthread_setschedparam(pthread_self(), policy, ¶m); |
|
|
pthread_setschedparam(pthread_self(), policy, ¶m); |
|
|
#elif defined ARCH_WIN |
|
|
#elif defined ARCH_WIN |
|
|
// Set entire process as realtime |
|
|
|
|
|
|
|
|
// Set process class first |
|
|
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); |
|
|
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); |
|
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); |
|
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); |
|
|
#endif |
|
|
#endif |
|
|