mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Fixed potential race condition in the non blocking thread pool
This commit is contained in:
parent
a071629fec
commit
2a54b70d45
@ -58,7 +58,7 @@ class NonBlockingThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
||||
}
|
||||
|
||||
~NonBlockingThreadPoolTempl() {
|
||||
done_.store(true, std::memory_order_relaxed);
|
||||
done_ = true;
|
||||
// Now if all threads block without work, they will start exiting.
|
||||
// But note that threads can continue to work arbitrary long,
|
||||
// block, submit new work, unblock and otherwise live full life.
|
||||
|
@ -12,6 +12,16 @@
|
||||
#include "main.h"
|
||||
#include "Eigen/CXX11/ThreadPool"
|
||||
|
||||
static void test_create_destroy_empty_pool()
|
||||
{
|
||||
// Just create and destroy the pool. This will wind up and tear down worker
|
||||
// threads. Ensure there are no issues in that logic.
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
NonBlockingThreadPool tp(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void test_parallelism()
|
||||
{
|
||||
// Test we never-ever fail to match available tasks with idle threads.
|
||||
@ -87,5 +97,6 @@ static void test_parallelism()
|
||||
|
||||
void test_cxx11_non_blocking_thread_pool()
|
||||
{
|
||||
CALL_SUBTEST(test_create_destroy_empty_pool());
|
||||
CALL_SUBTEST(test_parallelism());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user