diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-01-30 10:13:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-30 10:13:07 -0800 |
commit | 6bc97008eca2f8776f6fe4d480f3227d2a05a7c5 (patch) | |
tree | 1e52622d8862e9abefed182c7894f021c6f4d03e /src | |
parent | 52f115f8ea66467d8c500fa9b03d2deb98eaafa2 (diff) | |
download | binaryen-6bc97008eca2f8776f6fe4d480f3227d2a05a7c5.tar.gz binaryen-6bc97008eca2f8776f6fe4d480f3227d2a05a7c5.tar.bz2 binaryen-6bc97008eca2f8776f6fe4d480f3227d2a05a7c5.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/support/threads.cpp | 3 | ||||
-rw-r--r-- | src/support/threads.h | 2 |
2 files changed, 2 insertions, 3 deletions
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<std::mutex> 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(); |