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 | |
David Sanders | 6e70994 | 2022-04-05 06:49:26 | [diff] [blame] | 7 | #include "base/base_export.h" |
Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 8 | #include "base/feature_list.h" |
| 9 | |
| 10 | namespace base { |
| 11 | |
Francois Doray | ee4a553 | 2021-03-30 00:17:17 | [diff] [blame] | 12 | #if HAS_NATIVE_THREAD_POOL() |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame^] | 13 | BASE_FEATURE(kUseNativeThreadPool, |
| 14 | "UseNativeThreadPool", |
| 15 | base::FEATURE_DISABLED_BY_DEFAULT); |
| 16 | BASE_FEATURE(kUseBackgroundNativeThreadPool, |
| 17 | "UseBackgroundNativeThreadPool", |
| 18 | base::FEATURE_DISABLED_BY_DEFAULT); |
Aditya Keerthi | a41eda5 | 2019-04-01 15:03:25 | [diff] [blame] | 19 | #endif |
| 20 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame^] | 21 | BASE_FEATURE(kNoWorkerThreadReclaim, |
| 22 | "NoWorkerThreadReclaim", |
| 23 | base::FEATURE_DISABLED_BY_DEFAULT); |
Francois Doray | a20b6df2 | 2019-06-27 15:04:19 | [diff] [blame] | 24 | |
Patrick Monette | 6497eae | 2022-08-09 17:59:58 | [diff] [blame] | 25 | // static |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame^] | 26 | BASE_FEATURE(kNoWakeUpsForCanceledTasks, |
| 27 | "NoWakeUpsForCanceledTasks", |
| 28 | FEATURE_DISABLED_BY_DEFAULT); |
Patrick Monette | 6497eae | 2022-08-09 17:59:58 | [diff] [blame] | 29 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame^] | 30 | BASE_FEATURE(kRemoveCanceledTasksInTaskQueue, |
| 31 | "RemoveCanceledTasksInTaskQueue2", |
| 32 | base::FEATURE_DISABLED_BY_DEFAULT); |
Patrick Monette | eaaa238 | 2021-12-08 17:06:59 | [diff] [blame] | 33 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame^] | 34 | BASE_FEATURE(kAlwaysAbandonScheduledTask, |
| 35 | "AlwaysAbandonScheduledTask", |
| 36 | base::FEATURE_DISABLED_BY_DEFAULT); |
Patrick Monette | 4efba9c | 2022-08-18 16:41:32 | [diff] [blame] | 37 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame^] | 38 | BASE_FEATURE(kAddTaskLeewayFeature, |
| 39 | "AddTaskLeeway", |
| 40 | base::FEATURE_ENABLED_BY_DEFAULT); |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 41 | |
| 42 | const base::FeatureParam<TimeDelta> kTaskLeewayParam{&kAddTaskLeewayFeature, |
Jiahe Zhang | 07cf3313 | 2022-08-09 09:42:49 | [diff] [blame] | 43 | "leeway", kDefaultLeeway}; |
Etienne Pierre-doray | a879273 | 2022-02-05 02:27:25 | [diff] [blame] | 44 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame^] | 45 | BASE_FEATURE(kAlignWakeUps, "AlignWakeUps", base::FEATURE_ENABLED_BY_DEFAULT); |
Etienne Pierre-doray | 048472eb | 2022-02-07 16:24:48 | [diff] [blame] | 46 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame^] | 47 | BASE_FEATURE(kExplicitHighResolutionTimerWin, |
| 48 | "ExplicitHighResolutionTimerWin", |
| 49 | base::FEATURE_DISABLED_BY_DEFAULT); |
Etienne Pierre-doray | ae2c15a | 2022-04-29 18:50:59 | [diff] [blame] | 50 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame^] | 51 | BASE_FEATURE(kRunTasksByBatches, |
| 52 | "RunTasksByBatches", |
| 53 | base::FEATURE_DISABLED_BY_DEFAULT); |
Alex Attar | 9fcc01e | 2022-05-20 14:01:27 | [diff] [blame] | 54 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame^] | 55 | BASE_FEATURE(kBrowserPeriodicYieldingToNative, |
| 56 | "BrowserPeriodicYieldingToNative", |
| 57 | base::FEATURE_DISABLED_BY_DEFAULT); |
Stephen Nusko | 408b9a9 | 2022-09-15 10:03:57 | [diff] [blame] | 58 | |
| 59 | const BASE_EXPORT base::FeatureParam<base::TimeDelta> |
| 60 | kBrowserPeriodicYieldingToNativeNormalInputAfterMsParam{ |
| 61 | &kBrowserPeriodicYieldingToNative, |
| 62 | "yield_to_android_looper_after_ms_normal_input", base::Milliseconds(8)}; |
| 63 | |
| 64 | const BASE_EXPORT base::FeatureParam<base::TimeDelta> |
| 65 | kBrowserPeriodicYieldingToNativeFlingInputAfterMsParam{ |
| 66 | &kBrowserPeriodicYieldingToNative, |
| 67 | "yield_to_android_looper_after_ms_fling_input", base::Milliseconds(16)}; |
| 68 | |
| 69 | const BASE_EXPORT base::FeatureParam<base::TimeDelta> |
| 70 | kBrowserPeriodicYieldingToNativeNoInputAfterMsParam{ |
| 71 | &kBrowserPeriodicYieldingToNative, |
| 72 | "yield_to_android_looper_after_ms_no_input", base::Milliseconds(100)}; |
| 73 | |
| 74 | const BASE_EXPORT base::FeatureParam<base::TimeDelta> |
| 75 | kBrowserPeriodicYieldingToNativeDelay{&kBrowserPeriodicYieldingToNative, |
| 76 | "non_delayed_looper_defer_for_ns", |
| 77 | base::Nanoseconds(500000)}; |
| 78 | |
Jiahe Zhang | 07cf3313 | 2022-08-09 09:42:49 | [diff] [blame] | 79 | // Leeway value applied to delayed tasks. An atomic is used here because the |
| 80 | // value is queried from multiple threads. |
| 81 | std::atomic<TimeDelta> g_task_leeway{kDefaultLeeway}; |
| 82 | |
| 83 | BASE_EXPORT void InitializeTaskLeeway() { |
| 84 | g_task_leeway.store(kTaskLeewayParam.Get(), std::memory_order_relaxed); |
| 85 | } |
| 86 | |
| 87 | BASE_EXPORT TimeDelta GetTaskLeeway() { |
| 88 | return g_task_leeway.load(std::memory_order_relaxed); |
| 89 | } |
| 90 | |
Francois Doray | 5b44e33f | 2018-11-09 22:08:13 | [diff] [blame] | 91 | } // namespace base |