aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h
diff options
context:
space:
mode:
authorGravatar Rasmus Munk Larsen <rmlarsen@google.com>2016-06-23 16:40:07 -0700
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2016-06-23 16:40:07 -0700
commita9c1e4d7b7ce7c9dc5310cee1ed13fdef08e506e (patch)
tree0da9ce7e94a29f6fc1071b4b0286ad089f803dc5 /unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h
parentd39df320d29ecc678e019962dfb2bdf64b061197 (diff)
Return -1 from CurrentThreadId when called by thread outside the pool.
Diffstat (limited to 'unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h')
-rw-r--r--unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h b/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h
index 36eb6950f..e75d0f467 100644
--- a/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h
+++ b/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h
@@ -78,7 +78,7 @@ class SimpleThreadPoolTempl : public ThreadPoolInterface {
if (pt->pool == this) {
return pt->thread_id;
} else {
- return NumThreads();
+ return -1;
}
}
@@ -128,8 +128,9 @@ class SimpleThreadPoolTempl : public ThreadPoolInterface {
};
struct PerThread {
- ThreadPoolTempl* pool; // Parent pool, or null for normal threads.
- int thread_id; // Worker thread index in pool.
+ constexpr PerThread() : pool(NULL), thread_id(-1) { }
+ SimpleThreadPoolTempl* pool; // Parent pool, or null for normal threads.
+ int thread_id; // Worker thread index in pool.
};
Environment env_;
@@ -141,7 +142,7 @@ class SimpleThreadPoolTempl : public ThreadPoolInterface {
bool exiting_ = false;
PerThread* GetPerThread() const {
- static EIGEN_THREAD_LOCAL PerThread per_thread;
+ EIGEN_THREAD_LOCAL PerThread per_thread;
return &per_thread;
}
};