diff --git a/ThreadPool.h b/ThreadPool.h index 4183203..108741b 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 lg(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 lg(queue_mutex); stop = true; } condition.notify_all();