Remove use of base/synchronization in scheduler
1:1 replacment with std classes.
Change-Id: Ie753a49f84da32a8d440dd307a6f871d6fee2985
Reviewed-on: https://gn-review.googlesource.com/1700
Reviewed-by: Brett Wilson <brettw@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
diff --git a/tools/gn/scheduler.cc b/tools/gn/scheduler.cc
index 8da3035..00b5c61 100644
--- a/tools/gn/scheduler.cc
+++ b/tools/gn/scheduler.cc
@@ -18,7 +18,8 @@
: main_thread_run_loop_(MsgLoop::Current()),
input_file_manager_(new InputFileManager),
verbose_logging_(false),
- pool_work_count_cv_(&pool_work_count_lock_),
+ pool_work_count_lock_(),
+ pool_work_count_cv_(),
worker_pool_(),
is_failed_(false),
suppress_output_for_testing_(false),
@@ -72,8 +73,8 @@
std::move(work).Run();
self->DecrementWorkCount();
if (!self->pool_work_count_.Decrement()) {
- base::AutoLock auto_lock(self->pool_work_count_lock_);
- self->pool_work_count_cv_.Signal();
+ std::unique_lock<std::mutex> auto_lock(self->pool_work_count_lock_);
+ self->pool_work_count_cv_.notify_one();
}
},
this, std::move(work)));
@@ -179,7 +180,7 @@
}
void Scheduler::WaitForPoolTasks() {
- base::AutoLock lock(pool_work_count_lock_);
+ std::unique_lock<std::mutex> lock(pool_work_count_lock_);
while (!pool_work_count_.IsZero())
- pool_work_count_cv_.Wait();
+ pool_work_count_cv_.wait(lock);
}
diff --git a/tools/gn/scheduler.h b/tools/gn/scheduler.h
index a7af3d4..1677b4d 100644
--- a/tools/gn/scheduler.h
+++ b/tools/gn/scheduler.h
@@ -5,13 +5,13 @@
#ifndef TOOLS_GN_SCHEDULER_H_
#define TOOLS_GN_SCHEDULER_H_
+#include <condition_variable>
#include <map>
+#include <mutex>
#include "base/atomic_ref_count.h"
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/synchronization/condition_variable.h"
-#include "base/synchronization/lock.h"
#include "msg_loop.h"
#include "task.h"
#include "tools/gn/input_file_manager.h"
@@ -118,10 +118,10 @@
base::AtomicRefCount pool_work_count_;
// Lock for |pool_work_count_cv_|.
- base::Lock pool_work_count_lock_;
+ std::mutex pool_work_count_lock_;
// Condition variable signaled when |pool_work_count_| reaches zero.
- base::ConditionVariable pool_work_count_cv_;
+ std::condition_variable pool_work_count_cv_;
WorkerPool worker_pool_;