blob: fe789c4ee778079e1e3acfe9737a24768fce66bd [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
Hans-Filip Eloa7745f42022-10-18 18:41:227#include <atomic>
8
David Sanders6e709942022-04-05 06:49:269#include "base/base_export.h"
Leszek Swirski2987cc82018-11-05 15:19:2810#include "base/feature_list.h"
Olivier Li Shing Tat-Dupuisc42ff2e2023-10-13 15:43:0311#include "build/build_config.h"
Leszek Swirski2987cc82018-11-05 15:19:2812
13namespace base {
14
Gabriel Charettedfad5992022-10-28 17:57:1715// 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 Wangf8950ab62022-12-09 05:33:4225BASE_FEATURE(kUseUtilityThreadGroup,
26 "UseUtilityThreadGroup",
Takashi Toyoshimacff0ce62025-01-17 14:32:1227 FEATURE_DISABLED_BY_DEFAULT);
Zhibo Wangf8950ab62022-12-09 05:33:4228
Daniel Cheng0fff5c232022-09-21 17:43:3429BASE_FEATURE(kAddTaskLeewayFeature,
30 "AddTaskLeeway",
Takashi Toyoshimacff0ce62025-01-17 14:32:1231 FEATURE_ENABLED_BY_DEFAULT);
Etienne Pierre-doraya8792732022-02-05 02:27:2532
Takashi Toyoshimacff0ce62025-01-17 14:32:1233// Note: Do not use the prepared macro as of no need for a local cache.
34constinit const FeatureParam<TimeDelta> kTaskLeewayParam{
35 &kAddTaskLeewayFeature, "leeway", kDefaultLeeway};
36BASE_FEATURE_PARAM(TimeDelta,
37 kMaxPreciseDelay,
38 &kAddTaskLeewayFeature,
39 "max_precise_delay",
40 kDefaultMaxPreciseDelay);
Etienne Pierre-doraya8792732022-02-05 02:27:2541
Takashi Toyoshimacff0ce62025-01-17 14:32:1242BASE_FEATURE(kAlignWakeUps, "AlignWakeUps", FEATURE_DISABLED_BY_DEFAULT);
Etienne Pierre-doray048472eb2022-02-07 16:24:4843
Takashi Toyoshimacff0ce62025-01-17 14:32:1244BASE_FEATURE(kTimerSlackMac, "TimerSlackMac", FEATURE_DISABLED_BY_DEFAULT);
Etienne Pierre-doray1f2b04e2023-09-05 20:23:5645
Sean Maherbff1adc2024-04-10 20:33:4346BASE_FEATURE(kUIPumpImprovementsWin,
47 "UIPumpImprovementsWin",
Takashi Toyoshimacff0ce62025-01-17 14:32:1248 FEATURE_ENABLED_BY_DEFAULT);
Sean Maheracb46d72024-05-16 17:22:1549
50BASE_FEATURE(kPumpFastToSleepAndroid,
51 "PumpFastToSleepAndroid",
Takashi Toyoshimacff0ce62025-01-17 14:32:1252 FEATURE_ENABLED_BY_DEFAULT);
Sean Maherbff1adc2024-04-10 20:33:4353
Daniel Cheng0fff5c232022-09-21 17:43:3454BASE_FEATURE(kRunTasksByBatches,
55 "RunTasksByBatches",
François Doray179b0a82024-12-13 20:52:5756#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN)
Takashi Toyoshimacff0ce62025-01-17 14:32:1257 FEATURE_ENABLED_BY_DEFAULT);
Olivier Li Shing Tat-Dupuisc42ff2e2023-10-13 15:43:0358#else
Takashi Toyoshimacff0ce62025-01-17 14:32:1259 FEATURE_DISABLED_BY_DEFAULT);
Olivier Li Shing Tat-Dupuisc42ff2e2023-10-13 15:43:0360#endif
61
Takashi Toyoshimacff0ce62025-01-17 14:32:1262BASE_FEATURE(kThreadPoolCap2, "ThreadPoolCap2", FEATURE_DISABLED_BY_DEFAULT);
Edgar Arriagad096f402023-05-02 15:39:2463
Takashi Toyoshimacff0ce62025-01-17 14:32:1264// Note: Do not use the prepared macro as of no need for a local cache.
65constinit const FeatureParam<int> kThreadPoolCapRestrictedCount{
Edgar Arriaga453bcb12023-09-12 23:09:0166 &kThreadPoolCap2, "restricted_count", 3};
Alex Attar9fcc01e2022-05-20 14:01:2767
Francois Doray5b44e33f2018-11-09 22:08:1368} // namespace base