43 #include <sys/prctl.h>
66 return GetCurrentThread();
68 return pthread_self();
94 const DWORD MS_VC_EXCEPTION = 0x406D1388;
103 RaiseException(MS_VC_EXCEPTION, 0,
sizeof(info) /
sizeof(ULONG_PTR), (ULONG_PTR*)&info);
105 __except (EXCEPTION_EXECUTE_HANDLER)
128 DWORD thread_id = ::GetThreadId(
static_cast<HANDLE
>(thread.native_handle()));
131#elif defined(__APPLE__)
141 inline void set_thread_name(std::thread& thread,
const char* thread_name)
153 pthread_setname_np(thread_name);
162 inline void set_thread_name(std::thread& thread,
const char* thread_name)
164 pthread_setname_np(thread.native_handle(), thread_name);
174 prctl(PR_SET_NAME, thread_name, 0, 0, 0);
188 HRESULT hr = GetThreadDescription(
id, &data);
191 std::wstring str(data);
196 char thread_name[64];
197 if (pthread_getname_np(
id, thread_name,
sizeof(thread_name)) == 0)
216 std::wstringstream ss;
218#if defined(__GNUC__) && (__GNUC__ >= 11) && __linux__
221 std::hash<
decltype(id)> hasher;
222 std::size_t hash_value = hasher(
id) & mask;
223 ss << std::setfill(L
'0') << std::setw(4) << std::hex << std::uppercase << hash_value;
225 ss << std::setfill(L
'0') << std::setw(4) << std::hex << std::uppercase
226 << (
reinterpret_cast<std::size_t
>(id) & mask);
Provides concurrency primitives and abstractions for multithreaded programming. It features the power...
Definition message_manager.hpp:47
HANDLE thread_id_type
Definition thread.hpp:50
thread_id_type get_current_thread_id()
Retrieves the current thread's native identifier.
Definition thread.hpp:63
void set_thread_name(uint32_t dwThreadID, const char *thread_name)
Sets the name for a thread with a specified Thread ID.
Definition thread.hpp:92
struct cbeam::concurrency::tagTHREADNAME_INFO THREADNAME_INFO
std::wstring to_string(concurrency::thread_id_type id, std::size_t mask=(std::size_t) -1)
Returns a hexadecimal string representation of the given thread ID.
Definition thread.hpp:214
std::wstring get_thread_name(thread_id_type id)
Retrieves the name of the specified thread.
Definition thread.hpp:184
std::wstring from_string< std::wstring >(const std::string &str)
Converts the given std::string to std::wstring using UTF-8 to UTF-16 encoding.
Definition string.hpp:196
DWORD dwFlags
Definition thread.hpp:79
DWORD dwThreadID
Definition thread.hpp:78
DWORD dwType
Definition thread.hpp:76
LPCSTR szName
Definition thread.hpp:77
Header file to manage inclusion of windows.h with specific settings.