From 6bc97008eca2f8776f6fe4d480f3227d2a05a7c5 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 30 Jan 2018 10:13:07 -0800 Subject: Simplify ThreadPool::isRunning (#1391) * simplify ThreadPool::isRunning: it doesn't need to be static and to go through the global unique_ptr * it's undefined behavior to access the threadpool from a shutting down thread, as the parent is being destroyed --- src/support/threads.cpp | 3 +-- src/support/threads.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/support/threads.cpp b/src/support/threads.cpp index ce880ac2d..c4bb6e513 100644 --- a/src/support/threads.cpp +++ b/src/support/threads.cpp @@ -47,7 +47,6 @@ Thread::Thread(ThreadPool* parent) : parent(parent) { } Thread::~Thread() { - assert(!parent->isRunning()); { std::lock_guard lock(mutex); // notify the thread that it can exit @@ -194,7 +193,7 @@ size_t ThreadPool::size() { bool ThreadPool::isRunning() { DEBUG_POOL("check if running\n"); - return pool && pool->running; + return running; } void ThreadPool::notifyThreadIsReady() { diff --git a/src/support/threads.h b/src/support/threads.h index 280e19470..e76783ebb 100644 --- a/src/support/threads.h +++ b/src/support/threads.h @@ -104,7 +104,7 @@ public: size_t size(); - static bool isRunning(); + bool isRunning(); // Called by helper threads when they are free and ready. void notifyThreadIsReady(); -- cgit v1.2.3