mirror of
https://github.com/Chatterino/chatterino2.git
synced 2026-08-24 10:04:53 -05:00
29 lines
572 B
C++
29 lines
572 B
C++
#pragma once
|
|
|
|
#include <QString>
|
|
#include <QtGlobal>
|
|
|
|
#ifdef Q_OS_LINUX
|
|
# include <pthread.h>
|
|
#endif
|
|
|
|
namespace chatterino {
|
|
|
|
#ifdef Q_OS_WIN
|
|
namespace windows::detail {
|
|
void renameThread(void *hThread, const QString &name);
|
|
} // namespace windows::detail
|
|
#endif
|
|
|
|
template <typename T>
|
|
void renameThread(T &thread, const QString &threadName)
|
|
{
|
|
#ifdef Q_OS_LINUX
|
|
pthread_setname_np(thread.native_handle(), threadName.toLocal8Bit());
|
|
#elif defined(Q_OS_WIN)
|
|
windows::detail::renameThread(thread.native_handle(), threadName);
|
|
#endif
|
|
}
|
|
|
|
} // namespace chatterino
|