diff --git a/ext/native/thread/threadpool.cpp b/ext/native/thread/threadpool.cpp index cdb3db217a..37a99f737d 100644 --- a/ext/native/thread/threadpool.cpp +++ b/ext/native/thread/threadpool.cpp @@ -6,7 +6,6 @@ WorkerThread::WorkerThread() { thread.reset(new std::thread(std::bind(&WorkerThread::WorkFunc, this))); - while(!started) { }; } WorkerThread::~WorkerThread() { @@ -35,7 +34,6 @@ void WorkerThread::WaitForCompletion() { void WorkerThread::WorkFunc() { setCurrentThreadName("Worker"); std::unique_lock guard(mutex); - started = true; while (active) { // 'active == false' is one of the conditions for signaling, // do not "optimize" it @@ -54,7 +52,6 @@ void WorkerThread::WorkFunc() { LoopWorkerThread::LoopWorkerThread() : WorkerThread(true) { thread.reset(new std::thread(std::bind(&LoopWorkerThread::WorkFunc, this))); - while (!started) { }; } void LoopWorkerThread::Process(std::function work, int start, int end) { @@ -69,7 +66,6 @@ void LoopWorkerThread::Process(std::function work, int start, in void LoopWorkerThread::WorkFunc() { setCurrentThreadName("LoopWorker"); std::unique_lock guard(mutex); - started = true; while (active) { // 'active == false' is one of the conditions for signaling, // do not "optimize" it diff --git a/ext/native/thread/threadpool.h b/ext/native/thread/threadpool.h index ee4bcfef33..581302d7d2 100644 --- a/ext/native/thread/threadpool.h +++ b/ext/native/thread/threadpool.h @@ -27,7 +27,7 @@ protected: std::condition_variable signal; // used to signal new work std::condition_variable done; // used to signal work completion std::mutex mutex, doneMutex; // associated with each respective condition variable - volatile bool active = true, started = false; + bool active = true; int jobsDone = 0; int jobsTarget = 0; private: