Converts std::unique_lock to std::lock_guard.

Tested by compiling for CXX threads, OpenMP, no threads, and TBB.

Change-Id: If1ba5cfce83e2ad4e1015354ce67f5b23e89101f
This commit is contained in:
Mike Vitus
2018-04-10 17:20:07 -07:00
parent f973e107d2
commit 05fc04490f
5 changed files with 19 additions and 19 deletions
+3 -3
View File
@@ -62,7 +62,7 @@ ThreadPool::ThreadPool(int num_threads) {
}
ThreadPool::~ThreadPool() {
std::unique_lock<std::mutex> lock(thread_pool_mutex_);
std::lock_guard<std::mutex> lock(thread_pool_mutex_);
// Signal the thread workers to stop and wait for them to finish all scheduled
// tasks.
Stop();
@@ -72,7 +72,7 @@ ThreadPool::~ThreadPool() {
}
void ThreadPool::Resize(int num_threads) {
std::unique_lock<std::mutex> lock(thread_pool_mutex_);
std::lock_guard<std::mutex> lock(thread_pool_mutex_);
const int num_current_threads = thread_pool_.size();
if (num_current_threads >= num_threads) {
@@ -92,7 +92,7 @@ void ThreadPool::AddTask(const std::function<void()>& func) {
}
int ThreadPool::Size() {
std::unique_lock<std::mutex> lock(thread_pool_mutex_);
std::lock_guard<std::mutex> lock(thread_pool_mutex_);
return thread_pool_.size();
}