blob: f43abdffee4d143d103044622afe5e201459f579 [file] [log] [blame]
Leszek Swirski2987cc82018-11-05 15:19:281// Copyright 2018 The Chromium Authors. All rights reserved.
2// 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
Etienne Pierre-doray3ed41382019-02-06 04:40:4712const Feature kMayBlockWithoutDelay = {"MayBlockWithoutDelay",
13 base::FEATURE_DISABLED_BY_DEFAULT};
14
Etienne Pierre-dorayea2b21e2020-10-26 22:38:5915const Feature kDisableJobYield = {"DisableJobYield",
16 base::FEATURE_DISABLED_BY_DEFAULT};
17
18const Feature kDisableFairJobScheduling = {"DisableFairJobScheduling",
19 base::FEATURE_DISABLED_BY_DEFAULT};
20
21const Feature kDisableJobUpdatePriority = {"DisableJobUpdatePriority",
22 base::FEATURE_DISABLED_BY_DEFAULT};
23
24const Feature kWakeUpStrategyFeature = {"WakeUpStrategyFeature",
25 base::FEATURE_DISABLED_BY_DEFAULT};
26
27constexpr FeatureParam<WakeUpStrategy>::Option kWakeUpStrategyOptions[] = {
28 {WakeUpStrategy::kCentralizedWakeUps, "centralized-wakeups"},
29 {WakeUpStrategy::kSerializedWakeUps, "serialized-wakeups"},
Etienne Pierre-dorayb5fe0b5f2021-01-29 18:37:2730 {WakeUpStrategy::kExponentialWakeUps, "exponential-wakeups"},
31 {WakeUpStrategy::kGreedyWakeUps, "greedy-wakeups"}};
Etienne Pierre-dorayea2b21e2020-10-26 22:38:5932
33const base::FeatureParam<WakeUpStrategy> kWakeUpStrategyParam{
34 &kWakeUpStrategyFeature, "strategy", WakeUpStrategy::kExponentialWakeUps,
35 &kWakeUpStrategyOptions};
36
37const Feature kWakeUpAfterGetWork = {"WakeUpAfterGetWork",
38 base::FEATURE_DISABLED_BY_DEFAULT};
39
Francois Dorayee4a5532021-03-30 00:17:1740#if HAS_NATIVE_THREAD_POOL()
Aditya Keerthia41eda52019-04-01 15:03:2541const Feature kUseNativeThreadPool = {"UseNativeThreadPool",
42 base::FEATURE_DISABLED_BY_DEFAULT};
Francois Dorayee4a5532021-03-30 00:17:1743const Feature kUseBackgroundNativeThreadPool = {
44 "UseBackgroundNativeThreadPool", base::FEATURE_DISABLED_BY_DEFAULT};
Aditya Keerthia41eda52019-04-01 15:03:2545#endif
46
Francois Doraya20b6df22019-06-27 15:04:1947const Feature kUseFiveMinutesThreadReclaimTime = {
48 "UseFiveMinutesThreadReclaimTime", base::FEATURE_DISABLED_BY_DEFAULT};
49
Patrick Monette6497eae2022-08-09 17:59:5850// static
51const BASE_EXPORT Feature kNoWakeUpsForCanceledTasks{
52 "NoWakeUpsForCanceledTasks", FEATURE_DISABLED_BY_DEFAULT};
53
Patrick Monetteeaaa2382021-12-08 17:06:5954const BASE_EXPORT Feature kRemoveCanceledTasksInTaskQueue = {
Patrick Monetted85b8162022-01-27 00:23:2355 "RemoveCanceledTasksInTaskQueue2", base::FEATURE_DISABLED_BY_DEFAULT};
Patrick Monetteeaaa2382021-12-08 17:06:5956
Patrick Monette4efba9c2022-08-18 16:41:3257const BASE_EXPORT Feature kAlwaysAbandonScheduledTask = {
58 "AlwaysAbandonScheduledTask", base::FEATURE_DISABLED_BY_DEFAULT};
59
Etienne Pierre-doraya8792732022-02-05 02:27:2560const BASE_EXPORT Feature kAddTaskLeewayFeature = {
61 "AddTaskLeeway", base::FEATURE_ENABLED_BY_DEFAULT};
62
63const base::FeatureParam<TimeDelta> kTaskLeewayParam{&kAddTaskLeewayFeature,
Jiahe Zhang07cf33132022-08-09 09:42:4964 "leeway", kDefaultLeeway};
Etienne Pierre-doraya8792732022-02-05 02:27:2565
Etienne Pierre-doray048472eb2022-02-07 16:24:4866const BASE_EXPORT Feature kAlignWakeUps = {"AlignWakeUps",
67 base::FEATURE_DISABLED_BY_DEFAULT};
68
Etienne Pierre-dorayae2c15a2022-04-29 18:50:5969const BASE_EXPORT Feature kExplicitHighResolutionTimerWin = {
70 "ExplicitHighResolutionTimerWin", base::FEATURE_DISABLED_BY_DEFAULT};
71
Alex Attar9fcc01e2022-05-20 14:01:2772const BASE_EXPORT Feature kRunTasksByBatches = {
Alex Attar42c63be2022-06-02 18:58:1273 "RunTasksByBatches", base::FEATURE_DISABLED_BY_DEFAULT};
Alex Attar9fcc01e2022-05-20 14:01:2774
Jiahe Zhang07cf33132022-08-09 09:42:4975// Leeway value applied to delayed tasks. An atomic is used here because the
76// value is queried from multiple threads.
77std::atomic<TimeDelta> g_task_leeway{kDefaultLeeway};
78
79BASE_EXPORT void InitializeTaskLeeway() {
80 g_task_leeway.store(kTaskLeewayParam.Get(), std::memory_order_relaxed);
81}
82
83BASE_EXPORT TimeDelta GetTaskLeeway() {
84 return g_task_leeway.load(std::memory_order_relaxed);
85}
86
Francois Doray5b44e33f2018-11-09 22:08:1387} // namespace base