Commit aa62e6f3 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Set names in NamedThreadFactory in the new thread

Summary: This makes it now both work, and compile, on Windows.

Reviewed By: yfeldblum

Differential Revision: D5811100

fbshipit-source-id: 5d6bfc04ed8e60417615da15bd197769e0c79c11
parent d3e97eba
......@@ -33,10 +33,12 @@ class NamedThreadFactory : public ThreadFactory {
: prefix_(prefix.str()), suffix_(0) {}
std::thread newThread(Func&& func) override {
auto thread = std::thread(std::move(func));
folly::setThreadName(
thread.native_handle(), folly::to<std::string>(prefix_, suffix_++));
return thread;
auto name = folly::to<std::string>(prefix_, suffix_++);
return std::thread(
[ func = std::move(func), name = std::move(name) ]() mutable {
folly::setThreadName(name);
func();
});
}
void setNamePrefix(folly::StringPiece prefix) {
......
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