iw4x-client/src/Utils/Thread.hpp

24 lines
592 B
C++
Raw Normal View History

#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);
template <typename ...Args>
2022-12-17 18:54:41 +01:00
std::thread CreateNamedThread(const std::string& name, Args&&... args)
{
auto t = std::thread(std::forward<Args>(args)...);
2022-12-17 18:54:41 +01:00
SetName(t, name);
return t;
}
2022-12-17 18:54:41 +01:00
std::vector<DWORD> GetThreadIds();
void ForEachThread(const std::function<void(HANDLE)>& callback);
2022-12-17 18:54:41 +01:00
void SuspendOtherThreads();
void ResumeOtherThreads();
2022-06-04 14:59:14 +02:00
}