Rename the BasicPubSubManager thread

This commit is contained in:
Rasmus Karlsson 2023-12-03 13:51:58 +01:00
parent 934e518e18
commit 06cb7d5259
3 changed files with 23 additions and 0 deletions

View file

@ -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

View file

@ -8,6 +8,7 @@
#include "providers/twitch/PubSubHelpers.hpp"
#include "util/DebugCount.hpp"
#include "util/ExponentialBackoff.hpp"
#include "util/RenameThread.hpp"
#include <pajlada/signals/signal.hpp>
#include <QJsonObject>
@ -118,6 +119,8 @@ public:
this->mainThread_.reset(new std::thread([this] {
runThread();
}));
renameThread(*this->mainThread_.get(), "BPSM");
}
void stop()

19
src/util/RenameThread.hpp Normal file
View file

@ -0,0 +1,19 @@
#pragma once
#include <QtGlobal>
#ifdef Q_OS_LINUX
# include <pthread.h>
#endif
namespace chatterino {
template <typename T>
void renameThread(T &&thread, const char *threadName)
{
#ifdef Q_OS_LINUX
pthread_setname_np(thread.native_handle(), threadName);
#endif
}
} // namespace chatterino