blob: ab7d356c69a40d380c8a5d4609898b31bd8e6a6a [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#ifndef BASE_TASK_TASK_FEATURES_H_
6#define BASE_TASK_TASK_FEATURES_H_
7
8#include "base/base_export.h"
Etienne Pierre-Dorayd6b575b22018-11-21 19:32:299#include "base/metrics/field_trial_params.h"
Aditya Keerthia41eda52019-04-01 15:03:2510#include "build/build_config.h"
Leszek Swirski2987cc82018-11-05 15:19:2811
12namespace base {
13
14struct Feature;
Francois Doray5b44e33f2018-11-09 22:08:1315
16extern const BASE_EXPORT Feature kAllTasksUserBlocking;
Etienne Pierre-Dorayd6b575b22018-11-21 19:32:2917
Gabriel Charette3e2898f2019-05-01 14:55:0118// Under this feature, unused threads in ThreadGroup are only detached
Etienne Pierre-Dorayf9ef2182018-12-13 14:45:4219// if the total number of threads in the pool is above the initial capacity.
20extern const BASE_EXPORT Feature kNoDetachBelowInitialCapacity;
21
Etienne Pierre-doray3ed41382019-02-06 04:40:4722// Under this feature, workers blocked with MayBlock are replaced immediately
Etienne Pierre-dorayf7d85262019-11-20 23:37:0623// instead of waiting for a threshold in the foreground thread group.
Etienne Pierre-doray3ed41382019-02-06 04:40:4724extern const BASE_EXPORT Feature kMayBlockWithoutDelay;
25
Etienne Pierre-dorayea2b21e2020-10-26 22:38:5926// Under this feature, ThreadPool::ShouldYield() always returns false
27extern 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.
30extern const BASE_EXPORT Feature kDisableFairJobScheduling;
31// Under this feature, priority update on Jobs is disabled.
32extern const BASE_EXPORT Feature kDisableJobUpdatePriority;
33// Under this feature, another WorkerThread is signaled only after the current
34// thread was assigned work.
35extern const BASE_EXPORT Feature kWakeUpAfterGetWork;
36
37// Strategy affecting how WorkerThreads are signaled to pick up pending work.
38enum 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,
Etienne Pierre-dorayb5fe0b5f2021-01-29 18:37:2747 // Each thread signals as many threads as necessary, either when scheduling
48 // new work or picking up pending work.
49 kGreedyWakeUps,
Etienne Pierre-dorayea2b21e2020-10-26 22:38:5950};
51
52// Under this feature, a given WakeUpStrategy param is used.
53extern const BASE_EXPORT Feature kWakeUpStrategyFeature;
54extern const BASE_EXPORT base::FeatureParam<WakeUpStrategy>
55 kWakeUpStrategyParam;
56
Avi Drissman5b286372020-07-28 21:59:3857#if defined(OS_WIN) || defined(OS_APPLE)
Francois Doray7f777312019-05-16 12:26:3158#define HAS_NATIVE_THREAD_POOL() 1
59#else
60#define HAS_NATIVE_THREAD_POOL() 0
61#endif
62
63#if HAS_NATIVE_THREAD_POOL()
Gabriel Charette43fd3702019-05-29 16:36:5164// Under this feature, ThreadPoolImpl will use a ThreadGroup backed by a
Aditya Keerthia41eda52019-04-01 15:03:2565// native thread pool implementation. The Windows Thread Pool API and
66// libdispatch are used on Windows and macOS/iOS respectively.
67extern const BASE_EXPORT Feature kUseNativeThreadPool;
68#endif
69
Francois Doraya20b6df22019-06-27 15:04:1970// Whether threads in the ThreadPool should be reclaimed after being idle for 5
71// minutes, instead of 30 seconds.
72extern const BASE_EXPORT Feature kUseFiveMinutesThreadReclaimTime;
73
Leszek Swirski2987cc82018-11-05 15:19:2874} // namespace base
75
76#endif // BASE_TASK_TASK_FEATURES_H_