Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 1 | // 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 | #ifndef BASE_TASK_TASK_FEATURES_H_ |
| 6 | #define BASE_TASK_TASK_FEATURES_H_ |
| 7 | |
| 8 | #include "base/base_export.h" |
Etienne Pierre-Doray | d6b575b2 | 2018-11-21 19:32:29 | [diff] [blame] | 9 | #include "base/metrics/field_trial_params.h" |
Aditya Keerthi | a41eda5 | 2019-04-01 15:03:25 | [diff] [blame] | 10 | #include "build/build_config.h" |
Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 11 | |
| 12 | namespace base { |
| 13 | |
| 14 | struct Feature; |
Francois Doray | 5b44e33f | 2018-11-09 22:08:13 | [diff] [blame] | 15 | |
| 16 | extern const BASE_EXPORT Feature kAllTasksUserBlocking; |
Etienne Pierre-Doray | d6b575b2 | 2018-11-21 19:32:29 | [diff] [blame] | 17 | |
Gabriel Charette | 3e2898f | 2019-05-01 14:55:01 | [diff] [blame] | 18 | // Under this feature, unused threads in ThreadGroup are only detached |
Etienne Pierre-Doray | f9ef218 | 2018-12-13 14:45:42 | [diff] [blame] | 19 | // if the total number of threads in the pool is above the initial capacity. |
| 20 | extern const BASE_EXPORT Feature kNoDetachBelowInitialCapacity; |
| 21 | |
Etienne Pierre-doray | 3ed4138 | 2019-02-06 04:40:47 | [diff] [blame] | 22 | // Under this feature, workers blocked with MayBlock are replaced immediately |
Etienne Pierre-doray | f7d8526 | 2019-11-20 23:37:06 | [diff] [blame] | 23 | // instead of waiting for a threshold in the foreground thread group. |
Etienne Pierre-doray | 3ed4138 | 2019-02-06 04:40:47 | [diff] [blame] | 24 | extern const BASE_EXPORT Feature kMayBlockWithoutDelay; |
| 25 | |
Etienne Pierre-doray | ea2b21e | 2020-10-26 22:38:59 | [diff] [blame^] | 26 | // Under this feature, ThreadPool::ShouldYield() always returns false |
| 27 | extern const BASE_EXPORT Feature kDisableJobYield; |
| 28 | // Under this feature, JobTaskSource doesn't use worker count in its sort key |
| 29 | // such that worker threads are not distributed among running jobs equally. |
| 30 | extern const BASE_EXPORT Feature kDisableFairJobScheduling; |
| 31 | // Under this feature, priority update on Jobs is disabled. |
| 32 | extern const BASE_EXPORT Feature kDisableJobUpdatePriority; |
| 33 | // Under this feature, another WorkerThread is signaled only after the current |
| 34 | // thread was assigned work. |
| 35 | extern const BASE_EXPORT Feature kWakeUpAfterGetWork; |
| 36 | |
| 37 | // Strategy affecting how WorkerThreads are signaled to pick up pending work. |
| 38 | enum class WakeUpStrategy { |
| 39 | // A single thread scheduling new work signals all required WorkerThreads. |
| 40 | kCentralizedWakeUps, |
| 41 | // Each thread signals at most a single thread, either when scheduling new |
| 42 | // work or picking up pending work. |
| 43 | kSerializedWakeUps, |
| 44 | // Each thread signals at most 2 threads, either when scheduling new |
| 45 | // work or picking up pending work. |
| 46 | kExponentialWakeUps, |
| 47 | }; |
| 48 | |
| 49 | // Under this feature, a given WakeUpStrategy param is used. |
| 50 | extern const BASE_EXPORT Feature kWakeUpStrategyFeature; |
| 51 | extern const BASE_EXPORT base::FeatureParam<WakeUpStrategy> |
| 52 | kWakeUpStrategyParam; |
| 53 | |
Avi Drissman | 5b28637 | 2020-07-28 21:59:38 | [diff] [blame] | 54 | #if defined(OS_WIN) || defined(OS_APPLE) |
Francois Doray | 7f77731 | 2019-05-16 12:26:31 | [diff] [blame] | 55 | #define HAS_NATIVE_THREAD_POOL() 1 |
| 56 | #else |
| 57 | #define HAS_NATIVE_THREAD_POOL() 0 |
| 58 | #endif |
| 59 | |
| 60 | #if HAS_NATIVE_THREAD_POOL() |
Gabriel Charette | 43fd370 | 2019-05-29 16:36:51 | [diff] [blame] | 61 | // Under this feature, ThreadPoolImpl will use a ThreadGroup backed by a |
Aditya Keerthi | a41eda5 | 2019-04-01 15:03:25 | [diff] [blame] | 62 | // native thread pool implementation. The Windows Thread Pool API and |
| 63 | // libdispatch are used on Windows and macOS/iOS respectively. |
| 64 | extern const BASE_EXPORT Feature kUseNativeThreadPool; |
| 65 | #endif |
| 66 | |
Francois Doray | a20b6df2 | 2019-06-27 15:04:19 | [diff] [blame] | 67 | // Whether threads in the ThreadPool should be reclaimed after being idle for 5 |
| 68 | // minutes, instead of 30 seconds. |
| 69 | extern const BASE_EXPORT Feature kUseFiveMinutesThreadReclaimTime; |
| 70 | |
Leszek Swirski | 2987cc8 | 2018-11-05 15:19:28 | [diff] [blame] | 71 | } // namespace base |
| 72 | |
| 73 | #endif // BASE_TASK_TASK_FEATURES_H_ |