• 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 // This feature controls whether ThreadPool WorkerThreads should hold off waking
25 // up to purge PartitionAlloc within the first minute of their lifetime. See
26 // base::internal::GetSleepDurationBeforePurge.
27 BASE_EXPORT BASE_DECLARE_FEATURE(kDelayFirstWorkerWake);
28 
29 // Under this feature, a non-zero leeway is added to delayed tasks. Along with
30 // DelayPolicy, this affects the time at which a delayed task runs.
31 BASE_EXPORT BASE_DECLARE_FEATURE(kAddTaskLeewayFeature);
32 #if BUILDFLAG(IS_WIN)
33 constexpr TimeDelta kDefaultLeeway = Milliseconds(16);
34 #else
35 constexpr TimeDelta kDefaultLeeway = Milliseconds(8);
36 #endif  // #if !BUILDFLAG(IS_WIN)
37 extern const BASE_EXPORT base::FeatureParam<TimeDelta> kTaskLeewayParam;
38 
39 // We consider that delayed tasks above |kMaxPreciseDelay| never need
40 // DelayPolicy::kPrecise. The default value is slightly above 30Hz timer.
41 constexpr TimeDelta kDefaultMaxPreciseDelay = Milliseconds(36);
42 extern const BASE_EXPORT base::FeatureParam<TimeDelta> kMaxPreciseDelay;
43 
44 // Under this feature, wake ups are aligned at a 8ms boundary when allowed per
45 // DelayPolicy.
46 BASE_EXPORT BASE_DECLARE_FEATURE(kAlignWakeUps);
47 
48 // Under this feature, slack is added on mac message pumps that support it when
49 // allowed per DelayPolicy.
50 BASE_EXPORT BASE_DECLARE_FEATURE(kTimerSlackMac);
51 
52 // Under this feature, tasks that need high resolution timer are determined
53 // based on explicit DelayPolicy rather than based on a threshold.
54 BASE_EXPORT BASE_DECLARE_FEATURE(kExplicitHighResolutionTimerWin);
55 
56 // Under this feature, the Windows UI pump uses a WaitableEvent to wake itself
57 // up when not in a native nested loop. It also uses different control flow,
58 // calling Win32 MessagePump functions less often.
59 BASE_EXPORT BASE_DECLARE_FEATURE(kUIPumpImprovementsWin);
60 
61 // Under this feature, the Android pump will call ALooper_PollOnce() rather than
62 // unconditionally yielding to native to determine whether there exists native
63 // work to be done before sleep.
64 BASE_EXPORT BASE_DECLARE_FEATURE(kPumpFastToSleepAndroid);
65 
66 // Feature to run tasks by batches before pumping out messages.
67 BASE_EXPORT BASE_DECLARE_FEATURE(kRunTasksByBatches);
68 
69 }  // namespace base
70 
71 #endif  // BASE_TASK_TASK_FEATURES_H_
72