Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Unified Diff: base/task_scheduler/scheduler_worker_thread_unittest.cc

Issue 1876363004: TaskScheduler [11] Support ExecutionMode::SINGLE_THREADED. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@8_delayed
Patch Set: CR gab #20 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/task_scheduler/scheduler_worker_thread_unittest.cc
diff --git a/base/task_scheduler/scheduler_worker_thread_unittest.cc b/base/task_scheduler/scheduler_worker_thread_unittest.cc
index 36fa42369fd5ef7d79be6c305860660dcb81d56d..9eee5f374388ffcafd04cfa75383eb984bf4e91c 100644
--- a/base/task_scheduler/scheduler_worker_thread_unittest.cc
+++ b/base/task_scheduler/scheduler_worker_thread_unittest.cc
@@ -44,6 +44,11 @@ class TaskSchedulerWorkerThreadTest : public testing::TestWithParam<size_t> {
void TearDown() override {
worker_thread_->JoinForTesting();
+
+ {
+ AutoSchedulerLock auto_lock(main_entry_worker_thread_lock_);
+ EXPECT_EQ(worker_thread_.get(), main_entry_worker_thread_);
+ }
}
size_t TasksPerSequence() const { return GetParam(); }
@@ -91,7 +96,12 @@ class TaskSchedulerWorkerThreadTest : public testing::TestWithParam<size_t> {
: outer_(outer) {}
// SchedulerWorkerThread::Delegate:
- void OnMainEntry() override {
+ void OnMainEntry(SchedulerWorkerThread* worker_thread) override {
+ {
+ AutoSchedulerLock auto_lock(outer_->main_entry_worker_thread_lock_);
+ outer_->main_entry_worker_thread_ = worker_thread;
gab 2016/04/26 11:46:27 Why can't this directly compare to |worker_thread_
fdoray 2016/04/26 14:56:47 OnMainEntry() may be called before |worker_thread_
+ }
+
// Without synchronization, OnMainEntry() could be called twice without
// generating an error.
AutoSchedulerLock auto_lock(outer_->lock_);
@@ -200,6 +210,12 @@ class TaskSchedulerWorkerThreadTest : public testing::TestWithParam<size_t> {
// Number of times that RunTaskCallback() has been called.
size_t num_run_tasks_ = 0;
+ // Synchronizes access to |main_entry_worker_thread_|.
+ SchedulerLock main_entry_worker_thread_lock_;
+
+ // The worker thread argument passed to OnMainEntry().
+ SchedulerWorkerThread* main_entry_worker_thread_ = nullptr;
+
DISALLOW_COPY_AND_ASSIGN(TaskSchedulerWorkerThreadTest);
};

Powered by Google App Engine
This is Rietveld 408576698