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

ThreadPool: also lock run mutex before invalidating queue

parent 91915d3d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -150,8 +150,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()) {