mirror of
https://github.com/diamante0018/MW3ServerFreezer.git
synced 2025-07-04 18:21:56 +00:00
Refactor this (tekno gods dont sue please)
This commit is contained in:
21
src/common/utils/thread.hpp
Normal file
21
src/common/utils/thread.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
namespace utils::thread {
|
||||
bool set_name(HANDLE t, const std::string& name);
|
||||
bool set_name(DWORD id, const std::string& name);
|
||||
bool set_name(std::thread& t, const std::string& name);
|
||||
bool set_name(const std::string& name);
|
||||
|
||||
template <typename... Args>
|
||||
std::thread create_named_thread(const std::string& name, Args&&... args) {
|
||||
auto t = std::thread(std::forward<Args>(args)...);
|
||||
set_name(t, name);
|
||||
return t;
|
||||
}
|
||||
|
||||
std::vector<DWORD> get_thread_ids();
|
||||
void for_each_thread(const std::function<void(HANDLE)>& callback);
|
||||
|
||||
void suspend_other_threads();
|
||||
void resume_other_threads();
|
||||
} // namespace utils::thread
|
Reference in New Issue
Block a user