From 002e923cf1306c7773942a0bf10fb5172ff22432 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 7 Oct 2016 17:08:29 -0400 Subject: [PATCH] Added shutdown logic. --- Concurrency/AsyncTaskQueue.cpp | 1 + Concurrency/AsyncTaskQueue.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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_; }; }