From eb6ba00cc8a7e3164b19955a38ad94491d5a17e9 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Mon, 12 Sep 2016 10:31:55 -0700 Subject: [PATCH] Properly size the list of waiters --- unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h | 2 ++ unsupported/test/cxx11_eventcount.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h b/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h index 9f4e318e52..354bce52ae 100644 --- a/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h +++ b/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h @@ -29,6 +29,8 @@ class NonBlockingThreadPoolTempl : public Eigen::ThreadPoolInterface { spinning_(0), done_(false), ec_(waiters_) { + waiters_.resize(num_threads); + // Calculate coprimes of num_threads. // Coprimes are used for a random walk over all threads in Steal // and NonEmptyQueueIndex. Iteration is based on the fact that if we take diff --git a/unsupported/test/cxx11_eventcount.cpp b/unsupported/test/cxx11_eventcount.cpp index 366df9cee0..3b598bf424 100644 --- a/unsupported/test/cxx11_eventcount.cpp +++ b/unsupported/test/cxx11_eventcount.cpp @@ -26,6 +26,7 @@ int rand_reentrant(unsigned int* s) { static void test_basic_eventcount() { MaxSizeVector waiters(1); + waiters.resize(1); EventCount ec(waiters); EventCount::Waiter& w = waiters[0]; ec.Notify(false); @@ -82,6 +83,7 @@ static void test_stress_eventcount() static const int kQueues = 10; MaxSizeVector waiters(kThreads); + waiters.resize(kThreads); EventCount ec(waiters); TestQueue queues[kQueues];