diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86c24c15b..7f9c9146f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -486,6 +486,7 @@ set(SOURCE_FILES util/RapidjsonHelpers.hpp util/RatelimitBucket.cpp util/RatelimitBucket.hpp + util/RenameThread.hpp util/SampleData.cpp util/SampleData.hpp util/SharedPtrElementLess.hpp diff --git a/src/providers/liveupdates/BasicPubSubManager.hpp b/src/providers/liveupdates/BasicPubSubManager.hpp index fc0781147..58c4bbd75 100644 --- a/src/providers/liveupdates/BasicPubSubManager.hpp +++ b/src/providers/liveupdates/BasicPubSubManager.hpp @@ -8,6 +8,7 @@ #include "providers/twitch/PubSubHelpers.hpp" #include "util/DebugCount.hpp" #include "util/ExponentialBackoff.hpp" +#include "util/RenameThread.hpp" #include #include @@ -118,6 +119,8 @@ public: this->mainThread_.reset(new std::thread([this] { runThread(); })); + + renameThread(*this->mainThread_.get(), "BPSM"); } void stop() diff --git a/src/util/RenameThread.hpp b/src/util/RenameThread.hpp new file mode 100644 index 000000000..0cc1c6506 --- /dev/null +++ b/src/util/RenameThread.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +#ifdef Q_OS_LINUX +# include +#endif + +namespace chatterino { + +template +void renameThread(T &&thread, const char *threadName) +{ +#ifdef Q_OS_LINUX + pthread_setname_np(thread.native_handle(), threadName); +#endif +} + +} // namespace chatterino