Turned the constructor of the PerThread struct into what is effectively a constant expression to make the code compatible with a wider range of compilers

This commit is contained in:
Benoit Steiner 2016-06-22 16:03:11 -07:00
parent c58df31747
commit f8fcd6b32d

View File

@ -99,9 +99,7 @@ class NonBlockingThreadPoolTempl : public Eigen::ThreadPoolInterface {
typedef typename Environment::EnvThread Thread;
struct PerThread {
PerThread() : pool(NULL), index(-1) {
rand = std::hash<std::thread::id>()(std::this_thread::get_id());
}
PerThread() : pool(NULL), index(-1), rand(0) { }
NonBlockingThreadPoolTempl* pool; // Parent pool, or null for normal threads.
unsigned index; // Worker thread index in pool.
uint64_t rand; // Random generator state.
@ -122,6 +120,7 @@ class NonBlockingThreadPoolTempl : public Eigen::ThreadPoolInterface {
PerThread* pt = GetPerThread();
pt->pool = this;
pt->index = index;
pt->rand = std::hash<std::thread::id>()(std::this_thread::get_id());
Queue* q = queues_[index];
EventCount::Waiter* waiter = &waiters_[index];
for (;;) {