Commit 58171cb5 authored by Alexey Kuzmenko's avatar Alexey Kuzmenko Committed by Facebook GitHub Bot

only allocate trimmedName on win32

Reviewed By: yfeldblum

Differential Revision: D21921631

fbshipit-source-id: e905d6d2a96775a8c3b328fb78c8d32897f634f6
parent e31eb32a
......@@ -138,7 +138,6 @@ Optional<std::string> getCurrentThreadName() {
}
bool setThreadName(std::thread::id tid, StringPiece name) {
auto trimmedName = name.subpiece(0, kMaxThreadNameLength - 1).str();
#ifdef _WIN32
static_assert(
sizeof(unsigned int) == sizeof(std::thread::id),
......@@ -166,6 +165,8 @@ bool setThreadName(std::thread::id tid, StringPiece name) {
unsigned int id;
std::memcpy(&id, &tid, sizeof(id));
auto trimmedName = name.subpiece(0, kMaxThreadNameLength - 1).str();
TNIUnion tniUnion = {0x1000, trimmedName.data(), id, 0};
// This has to be in a separate stack frame from trimmedName, which requires
// C++ object destruction semantics.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment