Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors |
Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 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 | |
Hans-Filip Elo | a7745f4 | 2022-10-18 18:41:22 | [diff] [blame] | 7 | #include <atomic> |
| 8 | |
David Sanders | 6e70994 | 2022-04-05 06:49:26 | [diff] [blame] | 9 | #include "base/base_export.h" |
Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 10 | #include "base/feature_list.h" |
Olivier Li Shing Tat-Dupuis | c42ff2e | 2023-10-13 15:43:03 | [diff] [blame] | 11 | #include "build/build_config.h" |
Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 12 | |
| 13 | namespace base { |
| 14 | |
Gabriel Charette | dfad599 | 2022-10-28 17:57:17 | [diff] [blame] | 15 | // Note to implementers: thread pool code using task features must absolutely |
| 16 | // not invoke FeatureList::IsEnabled outside of the main thread. Doing so |
| 17 | // causes data races between worker threads and ~FeatureList when tests end |
| 18 | // (crbug.com/1344573). A reliable moment to query and cache the feature state |
| 19 | // is on ThreadPoolImpl::Start (and thus also on the first WorkerThread::Start, |
| 20 | // not the later ones) as this is invoked from the main thread after |
| 21 | // initializing the FeatureList. If caching the feature state in a static, you |
| 22 | // must be aware that all tests sharing a process will have the same state, |
| 23 | // regardless of future ScopedFeatureList instances. |
| 24 | |
Zhibo Wang | f8950ab6 | 2022-12-09 05:33:42 | [diff] [blame] | 25 | BASE_FEATURE(kUseUtilityThreadGroup, |
| 26 | "UseUtilityThreadGroup", |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 27 | FEATURE_DISABLED_BY_DEFAULT); |
Zhibo Wang | f8950ab6 | 2022-12-09 05:33:42 | [diff] [blame] | 28 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 29 | BASE_FEATURE(kAddTaskLeewayFeature, |
| 30 | "AddTaskLeeway", |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 31 | FEATURE_ENABLED_BY_DEFAULT); |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 32 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 33 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 34 | constinit const FeatureParam<TimeDelta> kTaskLeewayParam{ |
| 35 | &kAddTaskLeewayFeature, "leeway", kDefaultLeeway}; |
| 36 | BASE_FEATURE_PARAM(TimeDelta, |
| 37 | kMaxPreciseDelay, |
| 38 | &kAddTaskLeewayFeature, |
| 39 | "max_precise_delay", |
| 40 | kDefaultMaxPreciseDelay); |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 41 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 42 | BASE_FEATURE(kAlignWakeUps, "AlignWakeUps", FEATURE_DISABLED_BY_DEFAULT); |
Etienne Pierre-doray | 048472eb | 2022-02-07 16:24:48 | [diff] [blame] | 43 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 44 | BASE_FEATURE(kTimerSlackMac, "TimerSlackMac", FEATURE_DISABLED_BY_DEFAULT); |
Etienne Pierre-doray | 1f2b04e | 2023-09-05 20:23:56 | [diff] [blame] | 45 | |
Sean Maher | bff1adc | 2024-04-10 20:33:43 | [diff] [blame] | 46 | BASE_FEATURE(kUIPumpImprovementsWin, |
| 47 | "UIPumpImprovementsWin", |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 48 | FEATURE_ENABLED_BY_DEFAULT); |
Sean Maher | acb46d7 | 2024-05-16 17:22:15 | [diff] [blame] | 49 | |
| 50 | BASE_FEATURE(kPumpFastToSleepAndroid, |
| 51 | "PumpFastToSleepAndroid", |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 52 | FEATURE_ENABLED_BY_DEFAULT); |
Sean Maher | bff1adc | 2024-04-10 20:33:43 | [diff] [blame] | 53 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 54 | BASE_FEATURE(kRunTasksByBatches, |
| 55 | "RunTasksByBatches", |
François Doray | 179b0a8 | 2024-12-13 20:52:57 | [diff] [blame] | 56 | #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN) |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 57 | FEATURE_ENABLED_BY_DEFAULT); |
Olivier Li Shing Tat-Dupuis | c42ff2e | 2023-10-13 15:43:03 | [diff] [blame] | 58 | #else |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 59 | FEATURE_DISABLED_BY_DEFAULT); |
Olivier Li Shing Tat-Dupuis | c42ff2e | 2023-10-13 15:43:03 | [diff] [blame] | 60 | #endif |
| 61 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 62 | BASE_FEATURE(kThreadPoolCap2, "ThreadPoolCap2", FEATURE_DISABLED_BY_DEFAULT); |
Edgar Arriaga | d096f40 | 2023-05-02 15:39:24 | [diff] [blame] | 63 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 64 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 65 | constinit const FeatureParam<int> kThreadPoolCapRestrictedCount{ |
Edgar Arriaga | 453bcb1 | 2023-09-12 23:09:01 | [diff] [blame] | 66 | &kThreadPoolCap2, "restricted_count", 3}; |
Alex Attar | 9fcc01e | 2022-05-20 14:01:27 | [diff] [blame] | 67 | |
Francois Doray | 5b44e33f | 2018-11-09 22:08:13 | [diff] [blame] | 68 | } // namespace base |