2022-05-05 15:03:14 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Utils::Thread
|
|
|
|
{
|
2022-12-17 18:54:41 +01:00
|
|
|
bool SetName(HANDLE t, const std::string& name);
|
|
|
|
bool SetName(DWORD id, const std::string& name);
|
|
|
|
bool SetName(std::thread& t, const std::string& name);
|
|
|
|
bool SetName(const std::string& name);
|
2022-05-05 15:03:14 +01:00
|
|
|
|
|
|
|
template <typename ...Args>
|
2022-12-17 18:54:41 +01:00
|
|
|
std::thread CreateNamedThread(const std::string& name, Args&&... args)
|
2022-05-05 15:03:14 +01:00
|
|
|
{
|
|
|
|
auto t = std::thread(std::forward<Args>(args)...);
|
2022-12-17 18:54:41 +01:00
|
|
|
SetName(t, name);
|
2022-05-05 15:03:14 +01:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2022-12-17 18:54:41 +01:00
|
|
|
std::vector<DWORD> GetThreadIds();
|
|
|
|
void ForEachThread(const std::function<void(HANDLE)>& callback);
|
2022-05-05 15:03:14 +01:00
|
|
|
|
2022-12-17 18:54:41 +01:00
|
|
|
void SuspendOtherThreads();
|
|
|
|
void ResumeOtherThreads();
|
2022-06-04 14:59:14 +02:00
|
|
|
}
|