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

Unified Diff: base/task_scheduler/scheduler_worker_pool_impl_unittest.cc

Issue 2859053006: Use constexpr TaskTraits constructor in base (part 2). (Closed)
Patch Set: self-review Created 3 years, 7 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_pool_impl_unittest.cc
diff --git a/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc b/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc
index 6ee552946da03e232070f4475c0707584eb7b902..527f73c0b982ff554f2ab671be1bdc37451285b3 100644
--- a/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc
+++ b/base/task_scheduler/scheduler_worker_pool_impl_unittest.cc
@@ -113,7 +113,7 @@ scoped_refptr<TaskRunner> CreateTaskRunnerWithExecutionMode(
SchedulerWorkerPoolImpl* worker_pool,
test::ExecutionMode execution_mode) {
// Allow tasks posted to the returned TaskRunner to wait on a WaitableEvent.
- const TaskTraits traits = TaskTraits().WithBaseSyncPrimitives();
+ const TaskTraits traits = {WithBaseSyncPrimitives()};
switch (execution_mode) {
case test::ExecutionMode::PARALLEL:
return worker_pool->CreateTaskRunnerWithTraits(traits);
@@ -413,13 +413,11 @@ TEST_F(TaskSchedulerWorkerPoolImplPostTaskBeforeStartTest,
WaitableEvent barrier(WaitableEvent::ResetPolicy::MANUAL,
WaitableEvent::InitialState::NOT_SIGNALED);
- worker_pool_
- ->CreateTaskRunnerWithTraits(TaskTraits().WithBaseSyncPrimitives())
+ worker_pool_->CreateTaskRunnerWithTraits({WithBaseSyncPrimitives()})
->PostTask(FROM_HERE,
Bind(&TaskPostedBeforeStart, Unretained(&task_1_thread_ref),
Unretained(&task_1_scheduled), Unretained(&barrier)));
- worker_pool_
- ->CreateTaskRunnerWithTraits(TaskTraits().WithBaseSyncPrimitives())
+ worker_pool_->CreateTaskRunnerWithTraits({WithBaseSyncPrimitives()})
->PostTask(FROM_HERE,
Bind(&TaskPostedBeforeStart, Unretained(&task_2_thread_ref),
Unretained(&task_2_scheduled), Unretained(&barrier)));
@@ -491,8 +489,7 @@ TEST_F(TaskSchedulerWorkerPoolCheckTlsReuse, CheckDetachedThreads) {
std::vector<std::unique_ptr<test::TestTaskFactory>> factories;
for (size_t i = 0; i < kNumWorkersInWorkerPool; ++i) {
factories.push_back(MakeUnique<test::TestTaskFactory>(
- worker_pool_->CreateTaskRunnerWithTraits(
- TaskTraits().WithBaseSyncPrimitives()),
+ worker_pool_->CreateTaskRunnerWithTraits({WithBaseSyncPrimitives()}),
test::ExecutionMode::PARALLEL));
ASSERT_TRUE(factories.back()->PostTask(
PostNestedTask::NO,
@@ -564,7 +561,7 @@ TEST_F(TaskSchedulerWorkerPoolHistogramTest, NumTasksBetweenWaits) {
WaitableEvent::InitialState::NOT_SIGNALED);
CreateAndStartWorkerPool(TimeDelta::Max(), kNumWorkersInWorkerPool);
auto task_runner = worker_pool_->CreateSequencedTaskRunnerWithTraits(
- TaskTraits().WithBaseSyncPrimitives());
+ {WithBaseSyncPrimitives()});
// Post a task.
task_runner->PostTask(FROM_HERE,
@@ -607,8 +604,8 @@ TEST_F(TaskSchedulerWorkerPoolHistogramTest, NumTasksBetweenWaitsWithDetach) {
WaitableEvent tasks_can_exit_event(WaitableEvent::ResetPolicy::MANUAL,
WaitableEvent::InitialState::NOT_SIGNALED);
CreateAndStartWorkerPool(kReclaimTimeForDetachTests, kNumWorkersInWorkerPool);
- auto task_runner = worker_pool_->CreateTaskRunnerWithTraits(
- TaskTraits().WithBaseSyncPrimitives());
+ auto task_runner =
+ worker_pool_->CreateTaskRunnerWithTraits({WithBaseSyncPrimitives()});
// Post tasks to saturate the pool.
std::vector<std::unique_ptr<WaitableEvent>> task_started_events;
@@ -672,7 +669,7 @@ TEST_F(TaskSchedulerWorkerPoolHistogramTest, NumTasksBeforeDetach) {
auto histogrammed_thread_task_runner =
worker_pool_->CreateSequencedTaskRunnerWithTraits(
- TaskTraits().WithBaseSyncPrimitives());
+ {WithBaseSyncPrimitives()});
// Post 3 tasks and hold the thread for idle thread stack ordering.
// This test assumes |histogrammed_thread_task_runner| gets assigned the same
@@ -730,7 +727,7 @@ TEST_F(TaskSchedulerWorkerPoolHistogramTest, NumTasksBeforeDetach) {
WaitableEvent::InitialState::NOT_SIGNALED);
auto task_runner_for_top_idle =
worker_pool_->CreateSequencedTaskRunnerWithTraits(
- TaskTraits().WithBaseSyncPrimitives());
+ {WithBaseSyncPrimitives()});
task_runner_for_top_idle->PostTask(
FROM_HERE, BindOnce(
[](PlatformThreadRef thread_ref,

Powered by Google App Engine
This is Rietveld 408576698