• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_TASK_TASK_FEATURES_H_
6 #define BASE_TASK_TASK_FEATURES_H_
7 
8 #include "base/base_export.h"
9 #include "base/feature_list.h"
10 #include "base/metrics/field_trial_params.h"
11 #include "build/build_config.h"
12 
13 namespace base {
14 
15 // Under this feature, a utility_thread_group will be created for
16 // running USER_VISIBLE tasks.
17 BASE_EXPORT BASE_DECLARE_FEATURE(kUseUtilityThreadGroup);
18 
19 // Under this feature, worker threads are not reclaimed after a timeout. Rather,
20 // only excess workers are cleaned up immediately after finishing a task.
21 BASE_EXPORT BASE_DECLARE_FEATURE(kNoWorkerThreadReclaim);
22 
23 // This feature controls whether wake ups are possible for canceled tasks.
24 BASE_EXPORT BASE_DECLARE_FEATURE(kNoWakeUpsForCanceledTasks);
25 
26 // Controls whether or not canceled delayed tasks are removed from task queues.
27 BASE_EXPORT BASE_DECLARE_FEATURE(kRemoveCanceledTasksInTaskQueue);
28 
29 // This feature controls whether or not the scheduled task is always abandoned
30 // when a timer is stopped or reset. The re-use of the scheduled task is an
31 // optimization that ensures a timer can not leave multiple canceled tasks in
32 // the task queue. Meant to be used in conjunction with
33 // kRemoveCanceledTasksInTaskQueue.
34 BASE_EXPORT BASE_DECLARE_FEATURE(kAlwaysAbandonScheduledTask);
35 
36 // This feature controls whether ThreadPool WorkerThreads should hold off waking
37 // up to purge partition alloc within the first minute of their lifetime. See
38 // base::internal::GetSleepTimeBeforePurge.
39 BASE_EXPORT BASE_DECLARE_FEATURE(kDelayFirstWorkerWake);
40 
41 // Under this feature, a non-zero leeway is added to delayed tasks. Along with
42 // DelayPolicy, this affects the time at which a delayed task runs.
43 BASE_EXPORT BASE_DECLARE_FEATURE(kAddTaskLeewayFeature);
44 constexpr TimeDelta kDefaultLeeway = Milliseconds(8);
45 extern const BASE_EXPORT base::FeatureParam<TimeDelta> kTaskLeewayParam;
46 
47 // Under this feature, wake ups are aligned at a 8ms boundary when allowed per
48 // DelayPolicy.
49 BASE_EXPORT BASE_DECLARE_FEATURE(kAlignWakeUps);
50 
51 // Under this feature, tasks that need high resolution timer are determined
52 // based on explicit DelayPolicy rather than based on a threshold.
53 BASE_EXPORT BASE_DECLARE_FEATURE(kExplicitHighResolutionTimerWin);
54 
55 // Feature to run tasks by batches before pumping out messages.
56 BASE_EXPORT BASE_DECLARE_FEATURE(kRunTasksByBatches);
57 
58 BASE_EXPORT void InitializeTaskLeeway();
59 BASE_EXPORT TimeDelta GetTaskLeewayForCurrentThread();
60 BASE_EXPORT TimeDelta GetDefaultTaskLeeway();
61 
62 // Controls the max number of delayed tasks that can run before selecting an
63 // immediate task in sequence manager.
64 BASE_EXPORT BASE_DECLARE_FEATURE(kMaxDelayedStarvationTasks);
65 extern const BASE_EXPORT base::FeatureParam<int>
66     kMaxDelayedStarvationTasksParam;
67 
68 }  // namespace base
69 
70 #endif  // BASE_TASK_TASK_FEATURES_H_
71