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

Unified Diff: components/task_scheduler_util/initialization_util.cc

Issue 2501763002: Add Thread Standby Policy SchedulerWorkerPoolImpl (Closed)
Patch Set: Rebase to edc7bea Created 4 years, 1 month 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 | « base/threading/sequenced_worker_pool_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/task_scheduler_util/initialization_util.cc
diff --git a/components/task_scheduler_util/initialization_util.cc b/components/task_scheduler_util/initialization_util.cc
index ea67027e112d7d2bde6447f38718c087370ea4a9..748eae3a21bf00797099dd42209914564fb59f0c 100644
--- a/components/task_scheduler_util/initialization_util.cc
+++ b/components/task_scheduler_util/initialization_util.cc
@@ -21,6 +21,9 @@ namespace task_scheduler_util {
namespace {
+using StandbyThreadPolicy =
+ base::SchedulerWorkerPoolParams::StandbyThreadPolicy;
+
enum WorkerPoolType : size_t {
BACKGROUND_WORKER_POOL = 0,
BACKGROUND_FILE_IO_WORKER_POOL,
@@ -30,6 +33,7 @@ enum WorkerPoolType : size_t {
};
struct WorkerPoolVariationValues {
+ StandbyThreadPolicy standby_thread_policy;
int threads = 0;
base::TimeDelta detach_period;
};
@@ -39,11 +43,12 @@ struct WorkerPoolVariationValues {
//
// |pool_descriptor| is a semi-colon separated value string with the following
// items:
-// 1. Minimum Thread Count (int)
-// 2. Maximum Thread Count (int)
-// 3. Thread Count Multiplier (double)
-// 4. Thread Count Offset (int)
-// 5. Detach Time in Milliseconds (milliseconds)
+// 0. Minimum Thread Count (int)
+// 1. Maximum Thread Count (int)
+// 2. Thread Count Multiplier (double)
+// 3. Thread Count Offset (int)
+// 4. Detach Time in Milliseconds (milliseconds)
+// 5. Standby Thread Policy (string)
// Additional values may appear as necessary and will be ignored.
WorkerPoolVariationValues StringToWorkerPoolVariationValues(
const base::StringPiece pool_descriptor) {
@@ -67,6 +72,10 @@ WorkerPoolVariationValues StringToWorkerPoolVariationValues(
min, max, cores_multiplier, offset);
values.detach_period =
base::TimeDelta::FromMilliseconds(detach_milliseconds);
+ values.standby_thread_policy =
+ (tokens.size() >= 6 && tokens[5] == "lazy")
+ ? StandbyThreadPolicy::LAZY
+ : StandbyThreadPolicy::ONE;
return values;
}
DLOG(ERROR) << "Invalid Worker Pool Descriptor: " << pool_descriptor;
@@ -128,6 +137,7 @@ bool InitializeDefaultTaskScheduler(
params_vector.emplace_back(predefined_params.name,
predefined_params.priority_hint,
predefined_params.io_restriction,
+ variation_values.standby_thread_policy,
variation_values.threads,
variation_values.detach_period);
}
« no previous file with comments | « base/threading/sequenced_worker_pool_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698