|
|
@@ -3,9 +3,15 @@ |
|
|
|
#include <dirent.h> |
|
|
|
#include <sys/stat.h> |
|
|
|
|
|
|
|
#if defined ARCH_LIN |
|
|
|
#include <pthread.h> |
|
|
|
#include <sched.h> |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined ARCH_WIN |
|
|
|
#include <windows.h> |
|
|
|
#include <shellapi.h> |
|
|
|
#include <processthreadsapi.h> |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@@ -84,8 +90,23 @@ int getPhysicalCoreCount() { |
|
|
|
} |
|
|
|
|
|
|
|
void setThreadName(const std::string &name) { |
|
|
|
#if defined ARCH_LIN |
|
|
|
#if defined ARCH_LIN || defined ARCH_MAC |
|
|
|
pthread_setname_np(pthread_self(), name.c_str()); |
|
|
|
#elif defined ARCH_WIN |
|
|
|
SetThreadDescription(GetCurrentThread(), name.c_str()); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void setThreadRealTime() { |
|
|
|
#if defined ARCH_LIN || defined ARCH_MAC |
|
|
|
int policy = SCHED_RR; |
|
|
|
struct sched_param param; |
|
|
|
param.sched_priority = sched_get_priority_max(policy); |
|
|
|
pthread_setschedparam(pthread_self(), policy, ¶m); |
|
|
|
#elif defined ARCH_WIN |
|
|
|
// Set entire process as realtime |
|
|
|
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); |
|
|
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|