task_features.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #ifndef BASE_TASK_TASK_FEATURES_H_
  5. #define BASE_TASK_TASK_FEATURES_H_
  6. #include "base/base_export.h"
  7. #include "base/metrics/field_trial_params.h"
  8. #include "build/build_config.h"
  9. namespace base {
  10. struct Feature;
  11. extern const BASE_EXPORT Feature kAllTasksUserBlocking;
  12. // Under this feature, unused threads in ThreadGroup are only detached
  13. // if the total number of threads in the pool is above the initial capacity.
  14. extern const BASE_EXPORT Feature kNoDetachBelowInitialCapacity;
  15. // Under this feature, workers blocked with MayBlock are replaced immediately
  16. // instead of waiting for a threshold in the foreground thread group.
  17. extern const BASE_EXPORT Feature kMayBlockWithoutDelay;
  18. // Under this feature, best effort capacity is never increased.
  19. // While it's unlikely we'd ship this as-is, this experiment allows us to
  20. // determine whether blocked worker replacement logic on best-effort tasks has
  21. // any impact on guardian metrics.
  22. extern const BASE_EXPORT Feature kFixedMaxBestEffortTasks;
  23. #if defined(OS_WIN) || defined(OS_MACOSX)
  24. #define HAS_NATIVE_THREAD_POOL() 1
  25. #else
  26. #define HAS_NATIVE_THREAD_POOL() 0
  27. #endif
  28. #if HAS_NATIVE_THREAD_POOL()
  29. // Under this feature, ThreadPoolImpl will use a ThreadGroup backed by a
  30. // native thread pool implementation. The Windows Thread Pool API and
  31. // libdispatch are used on Windows and macOS/iOS respectively.
  32. extern const BASE_EXPORT Feature kUseNativeThreadPool;
  33. #endif
  34. // Whether threads in the ThreadPool should be reclaimed after being idle for 5
  35. // minutes, instead of 30 seconds.
  36. extern const BASE_EXPORT Feature kUseFiveMinutesThreadReclaimTime;
  37. } // namespace base
  38. #endif // BASE_TASK_TASK_FEATURES_H_