Commit a8aa2c24 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

ThreadPool: also lock run mutex before invalidating queue

(cherry picked from commit b5fd9f03)
parent b77928ff
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -141,8 +141,12 @@ void ThreadPool::worker(size_t min_thread_buffer,
}

void ThreadPool::destroy() {
    // Lock run mutex to synchronize with queue
    std::unique_lock<std::mutex> lock{run_mutex_};
    done_ = true;
    queue_.invalidate();
    run_condition_.notify_all();
    lock.unlock();

    for(auto& thread : threads_) {
        if(thread.joinable()) {