diff --git a/Concurrency/AsyncTaskQueue.cpp b/Concurrency/AsyncTaskQueue.cpp index 7f5e5a68d..6f9f40027 100644 --- a/Concurrency/AsyncTaskQueue.cpp +++ b/Concurrency/AsyncTaskQueue.cpp @@ -43,6 +43,7 @@ AsyncTaskQueue::~AsyncTaskQueue() { should_destruct_ = true; enqueue([](){}); + thread_->join(); } void AsyncTaskQueue::enqueue(std::function function) diff --git a/Concurrency/AsyncTaskQueue.hpp b/Concurrency/AsyncTaskQueue.hpp index 00653d420..5cb14125f 100644 --- a/Concurrency/AsyncTaskQueue.hpp +++ b/Concurrency/AsyncTaskQueue.hpp @@ -31,7 +31,7 @@ class AsyncTaskQueue { std::mutex queue_mutex_; std::list> pending_tasks_; std::condition_variable processing_condition_; - bool should_destruct_; + std::atomic_bool should_destruct_; }; }