Add ProfilerRegisterThead() to PosixThread.
Adds an #ifdef'd block that calls ProfilerRegisterThread() if
"REGISTER_THREAD_GOOGLE_PERFTOOLS" is set. Apparently, this makes the
Google perftools CPU profiler work much better on x86-64.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666358 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/PosixThreadFactory.cpp b/lib/cpp/src/concurrency/PosixThreadFactory.cpp
index 27c5dfa..5995341 100644
--- a/lib/cpp/src/concurrency/PosixThreadFactory.cpp
+++ b/lib/cpp/src/concurrency/PosixThreadFactory.cpp
@@ -7,6 +7,10 @@
#include "PosixThreadFactory.h"
#include "Exception.h"
+#if GOOGLE_PERFTOOLS_REGISTER_THREAD
+# include <google/profiler.h>
+#endif
+
#include <assert.h>
#include <pthread.h>
@@ -162,6 +166,10 @@
return (void*)0;
}
+#if GOOGLE_PERFTOOLS_REGISTER_THREAD
+ ProfilerRegisterThread();
+#endif
+
thread->state_ = starting;
thread->runnable()->run();
if (thread->state_ != stopping && thread->state_ != stopped) {