Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion source/threads/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ size_t thread::hardware_concurrency() noexcept {
#ifdef CRCPP_WIN_OS

# include <Windows.h>
# include <VersionHelpers.h>

void thread::set_name(std::string_view name) noexcept {
const std::wstring utf16_name(name.begin(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about making the wstring construction conditional too?

name.end()); // concurrencpp strings are always ASCII (english only)
::SetThreadDescription(::GetCurrentThread(), utf16_name.data());
if (IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN10), LOBYTE(_WIN32_WINNT_WIN10), 14393)) {
// Windows 10 1607 or greater, use SetThreadDescription
::SetThreadDescription(::GetCurrentThread(), utf16_name.c_str());
} else {
// Windows version is less than Windows 10, do nothing
}
}

#elif defined(CRCPP_MINGW_OS)
Expand Down