• 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 // Fixed amount of threads that will be used as a cap for thread pools.
16 BASE_EXPORT BASE_DECLARE_FEATURE(kThreadPoolCap2);
17 
18 extern const BASE_EXPORT base::FeatureParam<int> kThreadPoolCapRestrictedCount;
19 
20 // Under this feature, a utility_thread_group will be created for
21 // running USER_VISIBLE tasks.
22 BASE_EXPORT BASE_DECLARE_FEATURE(kUseUtilityThreadGroup);
23 
24 // Under this feature, worker threads are not reclaimed after a timeout. Rather,
25 // only excess workers are cleaned up immediately after finishing a task.
26 BASE_EXPORT BASE_DECLARE_FEATURE(kNoWorkerThreadReclaim);
27 
28 // This feature controls whether ThreadPool WorkerThreads should hold off waking
29 // up to purge partition alloc within the first minute of their lifetime. See
30 // base::internal::GetSleepTimeBeforePurge.
31 BASE_EXPORT BASE_DECLARE_FEATURE(kDelayFirstWorkerWake);
32 
33 // Under this feature, a non-zero leeway is added to delayed tasks. Along with
34 // DelayPolicy, this affects the time at which a delayed task runs.
35 BASE_EXPORT BASE_DECLARE_FEATURE(kAddTaskLeewayFeature);
36 #if BUILDFLAG(IS_WIN)
37 constexpr TimeDelta kDefaultLeeway = Milliseconds(16);
38 #else
39 constexpr TimeDelta kDefaultLeeway = Milliseconds(8);
40 #endif  // #if !BUILDFLAG(IS_WIN)
41 extern const BASE_EXPORT base::FeatureParam<TimeDelta> kTaskLeewayParam;
42 
43 // We consider that delayed tasks above |kMaxPreciseDelay| never need
44 // DelayPolicy::kPrecise. The default value is slightly above 30Hz timer.
45 constexpr TimeDelta kDefaultMaxPreciseDelay = Milliseconds(36);
46 extern const BASE_EXPORT base::FeatureParam<TimeDelta> kMaxPreciseDelay;
47 
48 // Under this feature, wake ups are aligned at a 8ms boundary when allowed per
49 // DelayPolicy.
50 BASE_EXPORT BASE_DECLARE_FEATURE(kAlignWakeUps);
51 
52 // Under this feature, slack is added on mac message pumps that support it when
53 // allowed per DelayPolicy.
54 BASE_EXPORT BASE_DECLARE_FEATURE(kTimerSlackMac);
55 
56 // Under this feature, tasks that need high resolution timer are determined
57 // based on explicit DelayPolicy rather than based on a threshold.
58 BASE_EXPORT BASE_DECLARE_FEATURE(kExplicitHighResolutionTimerWin);
59 
60 // Feature to run tasks by batches before pumping out messages.
61 BASE_EXPORT BASE_DECLARE_FEATURE(kRunTasksByBatches);
62 
63 BASE_EXPORT void InitializeTaskLeeway();
64 BASE_EXPORT TimeDelta GetTaskLeewayForCurrentThread();
65 BASE_EXPORT TimeDelta GetDefaultTaskLeeway();
66 
67 // Controls the max number of delayed tasks that can run before selecting an
68 // immediate task in sequence manager.
69 BASE_EXPORT BASE_DECLARE_FEATURE(kMaxDelayedStarvationTasks);
70 extern const BASE_EXPORT base::FeatureParam<int>
71     kMaxDelayedStarvationTasksParam;
72 
73 // Feature to use a JobTaskSource implementation that minimizes lock contention.
74 BASE_EXPORT BASE_DECLARE_FEATURE(kUseNewJobImplementation);
75 
76 }  // namespace base
77 
78 #endif  // BASE_TASK_TASK_FEATURES_H_
79