diff --git a/Concurrency/AsyncTaskQueue.cpp b/Concurrency/AsyncTaskQueue.cpp index 798683c39..66b0fdaa3 100644 --- a/Concurrency/AsyncTaskQueue.cpp +++ b/Concurrency/AsyncTaskQueue.cpp @@ -88,16 +88,17 @@ DeferringAsyncTaskQueue::~DeferringAsyncTaskQueue() { void DeferringAsyncTaskQueue::defer(std::function function) { if(!deferred_tasks_) { - deferred_tasks_ = std::make_shared>>(); + deferred_tasks_ = std::make_unique>>(); } deferred_tasks_->push_back(function); } void DeferringAsyncTaskQueue::perform() { if(!deferred_tasks_) return; - std::shared_ptr>> deferred_tasks = deferred_tasks_; + auto deferred_tasks_raw = deferred_tasks_.release(); deferred_tasks_.reset(); - enqueue([deferred_tasks] { + enqueue([deferred_tasks_raw] { + std::unique_ptr>> deferred_tasks(deferred_tasks_raw); for(const auto &function : *deferred_tasks) { function(); } diff --git a/Concurrency/AsyncTaskQueue.hpp b/Concurrency/AsyncTaskQueue.hpp index da5d052c8..2962e329c 100644 --- a/Concurrency/AsyncTaskQueue.hpp +++ b/Concurrency/AsyncTaskQueue.hpp @@ -93,9 +93,7 @@ class DeferringAsyncTaskQueue: public AsyncTaskQueue { void flush(); private: - // TODO: this is a shared_ptr because of the issues capturing moveables in C++11; - // switch to a unique_ptr if/when adapting to C++14 - std::shared_ptr>> deferred_tasks_; + std::unique_ptr>> deferred_tasks_; }; }