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

Side by Side Diff: base/task_scheduler/scheduler_worker_pool_impl_unittest.cc

Issue 2340793002: TaskScheduler: Match behavior of SequencedWorkerPool in RunsTasksOnCurrentThread(). (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « base/task_scheduler/scheduler_worker_pool_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/task_scheduler/scheduler_worker_pool_impl.h" 5 #include "base/task_scheduler/scheduler_worker_pool_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <unordered_set> 10 #include <unordered_set>
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 320
321 // Fast-forward time and post tasks that are ripe for execution. 321 // Fast-forward time and post tasks that are ripe for execution.
322 delayed_task_manager_.SetCurrentTime( 322 delayed_task_manager_.SetCurrentTime(
323 delayed_task_manager_.GetDelayedRunTime()); 323 delayed_task_manager_.GetDelayedRunTime());
324 delayed_task_manager_.PostReadyTasks(); 324 delayed_task_manager_.PostReadyTasks();
325 325
326 // The task should run. 326 // The task should run.
327 task_ran.Wait(); 327 task_ran.Wait();
328 } 328 }
329 329
330 // Verify that the RunsTasksOnCurrentThread() method of a SEQUENCED TaskRunner
331 // returns false when called from a task that isn't part of the sequence.
332 TEST_P(TaskSchedulerWorkerPoolImplTest, SequencedRunsTasksOnCurrentThread) {
333 scoped_refptr<TaskRunner> task_runner(
334 worker_pool_->CreateTaskRunnerWithTraits(TaskTraits(), GetParam()));
335 scoped_refptr<TaskRunner> sequenced_task_runner(
336 worker_pool_->CreateTaskRunnerWithTraits(TaskTraits(),
337 ExecutionMode::SEQUENCED));
338
339 WaitableEvent task_ran(WaitableEvent::ResetPolicy::MANUAL,
340 WaitableEvent::InitialState::NOT_SIGNALED);
341 task_runner->PostTask(
342 FROM_HERE,
343 Bind(
344 [](scoped_refptr<TaskRunner> sequenced_task_runner,
345 WaitableEvent* task_ran) {
346 EXPECT_FALSE(sequenced_task_runner->RunsTasksOnCurrentThread());
robliao 2016/09/14 15:50:27 We only ever check for false for RunsTasksOnCurren
fdoray 2016/09/14 16:56:44 This is already tested by https://cs.chromium.org/
robliao 2016/09/14 17:20:42 Gotcha. Let's add a quick comment about that here
fdoray 2016/09/15 12:19:01 Done. Added comment about TestTaskFactory in this
347 task_ran->Signal();
348 },
349 sequenced_task_runner, Unretained(&task_ran)));
350 task_ran.Wait();
351 }
352
330 INSTANTIATE_TEST_CASE_P(Parallel, 353 INSTANTIATE_TEST_CASE_P(Parallel,
331 TaskSchedulerWorkerPoolImplTest, 354 TaskSchedulerWorkerPoolImplTest,
332 ::testing::Values(ExecutionMode::PARALLEL)); 355 ::testing::Values(ExecutionMode::PARALLEL));
333 INSTANTIATE_TEST_CASE_P(Sequenced, 356 INSTANTIATE_TEST_CASE_P(Sequenced,
334 TaskSchedulerWorkerPoolImplTest, 357 TaskSchedulerWorkerPoolImplTest,
335 ::testing::Values(ExecutionMode::SEQUENCED)); 358 ::testing::Values(ExecutionMode::SEQUENCED));
336 INSTANTIATE_TEST_CASE_P(SingleThreaded, 359 INSTANTIATE_TEST_CASE_P(SingleThreaded,
337 TaskSchedulerWorkerPoolImplTest, 360 TaskSchedulerWorkerPoolImplTest,
338 ::testing::Values(ExecutionMode::SINGLE_THREADED)); 361 ::testing::Values(ExecutionMode::SINGLE_THREADED));
339 362
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 count_waiter->Wait(); 571 count_waiter->Wait();
549 572
550 EXPECT_GT(subtle::NoBarrier_Load(&zero_tls_values_), 0); 573 EXPECT_GT(subtle::NoBarrier_Load(&zero_tls_values_), 0);
551 574
552 // Release tasks waiting on |waiter_|. 575 // Release tasks waiting on |waiter_|.
553 waiter_.Signal(); 576 waiter_.Signal();
554 } 577 }
555 578
556 } // namespace internal 579 } // namespace internal
557 } // namespace base 580 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_worker_pool_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698