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

Unified Diff: base/task_scheduler/task_scheduler.cc

Issue 2791423003: Initialize TaskScheduler with InitParams in CreateAndSetSimpleTaskScheduler(). (Closed)
Patch Set: 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/task_scheduler/task_scheduler.cc
diff --git a/base/task_scheduler/task_scheduler.cc b/base/task_scheduler/task_scheduler.cc
index bff2de65a422e5be152e8d4b1b29f9233fd127da..69a1a5ff8db6a98176cc23884706213f0cef1b71 100644
--- a/base/task_scheduler/task_scheduler.cc
+++ b/base/task_scheduler/task_scheduler.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/sys_info.h"
+#include "base/task_scheduler/initialization_util.h"
#include "base/task_scheduler/scheduler_worker_pool_params.h"
#include "base/task_scheduler/task_scheduler_impl.h"
#include "base/threading/platform_thread.h"
@@ -40,16 +41,39 @@ TaskScheduler::InitParams::~InitParams() = default;
#if !defined(OS_NACL)
// static
void TaskScheduler::CreateAndSetSimpleTaskScheduler(const std::string& name) {
- constexpr int kMinNumThreads = 1;
- std::vector<SchedulerWorkerPoolParams> worker_pool_params_vector;
- worker_pool_params_vector.emplace_back(
- name, ThreadPriority::NORMAL,
- SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY,
- std::max(kMinNumThreads, SysInfo::NumberOfProcessors()),
- TimeDelta::FromSeconds(30));
+ using StandbyThreadPolicy = SchedulerWorkerPoolParams::StandbyThreadPolicy;
+
+ constexpr TimeDelta kSuggestedReclaimTime = TimeDelta::FromSeconds(30);
+ constexpr int kMaxNumBackgroundThreads = 1;
+ constexpr int kMaxNumBackgroundBlockingThreads = 2;
+ constexpr int kMaxNumForegroundThreadsLowerBound = 2;
+ constexpr int kMaxNumForegroundThreadsUpperBound = 32;
+ constexpr double kMaxNumForegroundThreadsCoresMultiplier = 1;
+ constexpr int kMaxNumForegroundThreadsOffset = 0;
+ constexpr int kMaxNumForegroundBlockingThreadsLowerBound = 2;
+ constexpr int kMaxNumForegroundBlockingThreadsUpperBound = 64;
gab 2017/04/04 20:48:13 Why 32 and 64? Seems very high for a "simple" task
fdoray 2017/04/05 13:01:28 My thinking was that someone instantiating a simpl
robliao 2017/04/05 23:06:56 An alternative way to go about this is to adjust u
+ constexpr double kMaxNumForegroundBlockingThreadsCoresMultiplier = 2;
gab 2017/04/06 15:14:52 This isn't a MaxNum, it's a multiplier only, right
+ constexpr int kMaxNumForegroundBlockingThreadsOffset = 0;
+
CreateAndSetDefaultTaskScheduler(
- worker_pool_params_vector,
- Bind([](const TaskTraits&) -> size_t { return 0; }));
+ name, {{StandbyThreadPolicy::LAZY, kMaxNumBackgroundThreads,
+ kSuggestedReclaimTime},
+ {StandbyThreadPolicy::LAZY, kMaxNumBackgroundBlockingThreads,
+ kSuggestedReclaimTime},
+ {StandbyThreadPolicy::LAZY,
+ RecommendedMaxNumberOfThreadsInPool(
+ kMaxNumForegroundThreadsLowerBound,
+ kMaxNumForegroundThreadsUpperBound,
+ kMaxNumForegroundThreadsCoresMultiplier,
+ kMaxNumForegroundThreadsOffset),
+ kSuggestedReclaimTime},
+ {StandbyThreadPolicy::LAZY,
+ RecommendedMaxNumberOfThreadsInPool(
+ kMaxNumForegroundBlockingThreadsLowerBound,
+ kMaxNumForegroundBlockingThreadsUpperBound,
+ kMaxNumForegroundBlockingThreadsCoresMultiplier,
+ kMaxNumForegroundBlockingThreadsOffset),
+ kSuggestedReclaimTime}});
}
#endif // !defined(OS_NACL)
« 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