From 253c05562d6884ed7a828d5270fe1dc76b5e866a Mon Sep 17 00:00:00 2001 From: ppc Date: Tue, 4 Feb 2020 10:06:23 +0100 Subject: [PATCH] use lock_guard --- ThreadPool.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ThreadPool.h b/ThreadPool.h index 4183203..a59efa1 100644 --- a/ThreadPool.h +++ b/ThreadPool.h @@ -71,7 +71,7 @@ auto ThreadPool::enqueue(F&& f, Args&&... args) std::future res = task->get_future(); { - std::unique_lock lock(queue_mutex); + std::lock_guard lock(queue_mutex); // don't allow enqueueing after stopping the pool if(stop) @@ -87,7 +87,7 @@ auto ThreadPool::enqueue(F&& f, Args&&... args) inline ThreadPool::~ThreadPool() { { - std::unique_lock lock(queue_mutex); + std::lock_guard lock(queue_mutex); stop = true; } condition.notify_all();