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

Unified Diff: base/test/scoped_async_task_scheduler.cc

Issue 2795693006: Initialize TaskScheduler with InitParams in ScopedAsyncTaskScheduler. (Closed)
Patch Set: self-review Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/scoped_async_task_scheduler.cc
diff --git a/base/test/scoped_async_task_scheduler.cc b/base/test/scoped_async_task_scheduler.cc
index dcc5c15fb1549a4b24f325f5e14851362aba9be2..397243edb0588fa90778ee927e64f36f6ef3d25e 100644
--- a/base/test/scoped_async_task_scheduler.cc
+++ b/base/test/scoped_async_task_scheduler.cc
@@ -4,37 +4,33 @@
#include "base/test/scoped_async_task_scheduler.h"
-#include <vector>
-
-#include "base/bind.h"
#include "base/logging.h"
#include "base/task_scheduler/scheduler_worker_pool_params.h"
#include "base/task_scheduler/task_scheduler.h"
-#include "base/task_scheduler/task_scheduler_impl.h"
namespace base {
namespace test {
ScopedAsyncTaskScheduler::ScopedAsyncTaskScheduler() {
DCHECK(!TaskScheduler::GetInstance());
+
+ // Instantiate a TaskScheduler with 1 thread in each of its 4 pools. Threads
+ // stay alive even when they don't have work.
constexpr int kMaxThreads = 1;
const TimeDelta kSuggestedReclaimTime = TimeDelta::Max();
- std::vector<SchedulerWorkerPoolParams> worker_pool_params_vector;
- worker_pool_params_vector.emplace_back(
- "ScopedAsyncTaskScheduler", ThreadPriority::NORMAL,
- SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY, kMaxThreads,
+ const SchedulerWorkerPoolParams worker_pool_params(
+ SchedulerWorkerPoolParams::StandbyThreadPolicy::ONE, kMaxThreads,
kSuggestedReclaimTime);
TaskScheduler::CreateAndSetDefaultTaskScheduler(
- worker_pool_params_vector,
- Bind([](const TaskTraits&) -> size_t { return 0; }));
+ "ScopedAsync", {worker_pool_params, worker_pool_params,
+ worker_pool_params, worker_pool_params});
task_scheduler_ = TaskScheduler::GetInstance();
}
ScopedAsyncTaskScheduler::~ScopedAsyncTaskScheduler() {
DCHECK_EQ(TaskScheduler::GetInstance(), task_scheduler_);
TaskScheduler::GetInstance()->Shutdown();
- static_cast<internal::TaskSchedulerImpl*>(TaskScheduler::GetInstance())
- ->JoinForTesting();
+ TaskScheduler::GetInstance()->JoinForTesting();
TaskScheduler::SetInstance(nullptr);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698