Skip to content

Commit

Permalink
Simplify ThreadPool::isRunning (#1391)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kripken committed Jan 30, 2018
1 parent 52f115f commit 6bc9700
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/support/threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/support/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ThreadPool {

size_t size();

static bool isRunning();
bool isRunning();

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

0 comments on commit 6bc9700

Please sign in to comment.