diff --git a/game/system/SystemThread.cpp b/game/system/SystemThread.cpp index d96df8f142..9af0d955aa 100644 --- a/game/system/SystemThread.cpp +++ b/game/system/SystemThread.cpp @@ -1,6 +1,19 @@ #include "SystemThread.h" #include "common/log/log.h" +#include "common/util/unicode_util.h" + +#ifdef __linux +#include +#else +// Include order matters... +// clang-format off +#define NOMINMAX +#define WIN32_LEAN_AND_MEAN +#include +#include +// clang-format on +#endif ////////////////////// // Thread Manager // @@ -82,6 +95,13 @@ bool SystemThreadManager::all_threads_exiting() { void* bootstrap_thread_func(void* x) { SystemThread* thd = (SystemThread*)x; SystemThreadInterface iface(thd); + +#ifdef __linux__ + pthread_setname_np(pthread_self(), thd->name.c_str()); +#else + SetThreadDescription(GetCurrentThread(), (LPCWSTR)utf8_string_to_wide_string(thd->name).c_str()); +#endif + thd->function(iface); lg::debug("[SYSTEM] Thread {} is returning", thd->name.c_str()); return nullptr;