blob: 5a5d93129b7147b94c33437b6ab49e7f4ccb2220 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2018 The Chromium Authors
Leszek Swirski2987cc82018-11-05 15:19:282// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/task/task_features.h"
6
David Sanders6e709942022-04-05 06:49:267#include "base/base_export.h"
Leszek Swirski2987cc82018-11-05 15:19:288#include "base/feature_list.h"
9
10namespace base {
11
Francois Dorayee4a5532021-03-30 00:17:1712#if HAS_NATIVE_THREAD_POOL()
Aditya Keerthia41eda52019-04-01 15:03:2513const Feature kUseNativeThreadPool = {"UseNativeThreadPool",
14 base::FEATURE_DISABLED_BY_DEFAULT};
Francois Dorayee4a5532021-03-30 00:17:1715const Feature kUseBackgroundNativeThreadPool = {
16 "UseBackgroundNativeThreadPool", base::FEATURE_DISABLED_BY_DEFAULT};
Aditya Keerthia41eda52019-04-01 15:03:2517#endif
18
Etienne Pierre-dorayb2895232022-08-30 18:15:0319const Feature kNoWorkerThreadReclaim = {"NoWorkerThreadReclaim",
20 base::FEATURE_DISABLED_BY_DEFAULT};
Francois Doraya20b6df22019-06-27 15:04:1921
Patrick Monette6497eae2022-08-09 17:59:5822// static
23const BASE_EXPORT Feature kNoWakeUpsForCanceledTasks{
24 "NoWakeUpsForCanceledTasks", FEATURE_DISABLED_BY_DEFAULT};
25
Patrick Monetteeaaa2382021-12-08 17:06:5926const BASE_EXPORT Feature kRemoveCanceledTasksInTaskQueue = {
Patrick Monetted85b8162022-01-27 00:23:2327 "RemoveCanceledTasksInTaskQueue2", base::FEATURE_DISABLED_BY_DEFAULT};
Patrick Monetteeaaa2382021-12-08 17:06:5928
Patrick Monette4efba9c2022-08-18 16:41:3229const BASE_EXPORT Feature kAlwaysAbandonScheduledTask = {
30 "AlwaysAbandonScheduledTask", base::FEATURE_DISABLED_BY_DEFAULT};
31
Etienne Pierre-doraya8792732022-02-05 02:27:2532const BASE_EXPORT Feature kAddTaskLeewayFeature = {
33 "AddTaskLeeway", base::FEATURE_ENABLED_BY_DEFAULT};
34
35const base::FeatureParam<TimeDelta> kTaskLeewayParam{&kAddTaskLeewayFeature,
Jiahe Zhang07cf33132022-08-09 09:42:4936 "leeway", kDefaultLeeway};
Etienne Pierre-doraya8792732022-02-05 02:27:2537
Etienne Pierre-doray048472eb2022-02-07 16:24:4838const BASE_EXPORT Feature kAlignWakeUps = {"AlignWakeUps",
Etienne Pierre-doray3159e4182022-09-13 20:02:0339 base::FEATURE_ENABLED_BY_DEFAULT};
Etienne Pierre-doray048472eb2022-02-07 16:24:4840
Etienne Pierre-dorayae2c15a2022-04-29 18:50:5941const BASE_EXPORT Feature kExplicitHighResolutionTimerWin = {
42 "ExplicitHighResolutionTimerWin", base::FEATURE_DISABLED_BY_DEFAULT};
43
Alex Attar9fcc01e2022-05-20 14:01:2744const BASE_EXPORT Feature kRunTasksByBatches = {
Alex Attar42c63be2022-06-02 18:58:1245 "RunTasksByBatches", base::FEATURE_DISABLED_BY_DEFAULT};
Alex Attar9fcc01e2022-05-20 14:01:2746
Stephen Nusko408b9a92022-09-15 10:03:5747const BASE_EXPORT base::Feature kBrowserPeriodicYieldingToNative{
48 "BrowserPeriodicYieldingToNative", base::FEATURE_DISABLED_BY_DEFAULT};
49
50const BASE_EXPORT base::FeatureParam<base::TimeDelta>
51 kBrowserPeriodicYieldingToNativeNormalInputAfterMsParam{
52 &kBrowserPeriodicYieldingToNative,
53 "yield_to_android_looper_after_ms_normal_input", base::Milliseconds(8)};
54
55const BASE_EXPORT base::FeatureParam<base::TimeDelta>
56 kBrowserPeriodicYieldingToNativeFlingInputAfterMsParam{
57 &kBrowserPeriodicYieldingToNative,
58 "yield_to_android_looper_after_ms_fling_input", base::Milliseconds(16)};
59
60const BASE_EXPORT base::FeatureParam<base::TimeDelta>
61 kBrowserPeriodicYieldingToNativeNoInputAfterMsParam{
62 &kBrowserPeriodicYieldingToNative,
63 "yield_to_android_looper_after_ms_no_input", base::Milliseconds(100)};
64
65const BASE_EXPORT base::FeatureParam<base::TimeDelta>
66 kBrowserPeriodicYieldingToNativeDelay{&kBrowserPeriodicYieldingToNative,
67 "non_delayed_looper_defer_for_ns",
68 base::Nanoseconds(500000)};
69
Jiahe Zhang07cf33132022-08-09 09:42:4970// Leeway value applied to delayed tasks. An atomic is used here because the
71// value is queried from multiple threads.
72std::atomic<TimeDelta> g_task_leeway{kDefaultLeeway};
73
74BASE_EXPORT void InitializeTaskLeeway() {
75 g_task_leeway.store(kTaskLeewayParam.Get(), std::memory_order_relaxed);
76}
77
78BASE_EXPORT TimeDelta GetTaskLeeway() {
79 return g_task_leeway.load(std::memory_order_relaxed);
80}
81
Francois Doray5b44e33f2018-11-09 22:08:1382} // namespace base