Removing xe_thread_t.

This commit is contained in:
Ben Vanik
2014-08-16 01:36:45 -07:00
parent bca49bed4b
commit 01f0b14250
12 changed files with 69 additions and 216 deletions

View File

@@ -27,6 +27,36 @@ uint32_t current_thread_id() {
return static_cast<uint32_t>(GetCurrentThreadId());
}
// http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
#pragma pack(push, 8)
struct THREADNAME_INFO {
DWORD dwType; // Must be 0x1000.
LPCSTR szName; // Pointer to name (in user addr space).
DWORD dwThreadID; // Thread ID (-1=caller thread).
DWORD dwFlags; // Reserved for future use, must be zero.
};
#pragma pack(pop)
void set_name(DWORD thread_id, const std::string& name) {
if (!IsDebuggerPresent()) {
return;
}
THREADNAME_INFO info;
info.dwType = 0x1000;
info.szName = name.c_str();
info.dwThreadID = thread_id;
info.dwFlags = 0;
__try {
RaiseException(0x406D1388, 0, sizeof(info) / sizeof(ULONG_PTR),
reinterpret_cast<ULONG_PTR*>(&info));
}
__except(EXCEPTION_EXECUTE_HANDLER) {}
}
void set_name(const std::string& name) {
set_name(static_cast<DWORD>(-1), name);
}
void Yield() { SwitchToThread(); }
void Sleep(std::chrono::microseconds duration) {