Skip to content

Commit 6bc9700

Browse files
authored
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
1 parent 52f115f commit 6bc9700

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/support/threads.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ Thread::Thread(ThreadPool* parent) : parent(parent) {
4747
}
4848

4949
Thread::~Thread() {
50-
assert(!parent->isRunning());
5150
{
5251
std::lock_guard<std::mutex> lock(mutex);
5352
// notify the thread that it can exit
@@ -194,7 +193,7 @@ size_t ThreadPool::size() {
194193

195194
bool ThreadPool::isRunning() {
196195
DEBUG_POOL("check if running\n");
197-
return pool && pool->running;
196+
return running;
198197
}
199198

200199
void ThreadPool::notifyThreadIsReady() {

src/support/threads.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class ThreadPool {
104104

105105
size_t size();
106106

107-
static bool isRunning();
107+
bool isRunning();
108108

109109
// Called by helper threads when they are free and ready.
110110
void notifyThreadIsReady();

0 commit comments

Comments
 (0)