mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Return -1 from CurrentThreadId when called by thread outside the pool.
This commit is contained in:
@@ -99,13 +99,13 @@ class NonBlockingThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
||||
return static_cast<int>(threads_.size());
|
||||
}
|
||||
|
||||
int CurrentThreadId() const {
|
||||
int CurrentThreadId() const final {
|
||||
const PerThread* pt =
|
||||
const_cast<NonBlockingThreadPoolTempl*>(this)->GetPerThread();
|
||||
if (pt->pool == this) {
|
||||
return pt->thread_id;
|
||||
} else {
|
||||
return NumThreads();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,10 +113,10 @@ class NonBlockingThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
||||
typedef typename Environment::EnvThread Thread;
|
||||
|
||||
struct PerThread {
|
||||
constexpr PerThread() : pool(NULL), index(-1), rand(0) { }
|
||||
constexpr PerThread() : pool(NULL), rand(0), thread_id(-1) { }
|
||||
NonBlockingThreadPoolTempl* pool; // Parent pool, or null for normal threads.
|
||||
int thread_id; // Worker thread index in pool.
|
||||
uint64_t rand; // Random generator state.
|
||||
uint64_t rand; // Random generator state.
|
||||
int thread_id; // Worker thread index in pool.
|
||||
};
|
||||
|
||||
Environment env_;
|
||||
|
||||
Reference in New Issue
Block a user