task_features.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #if defined(OS_WIN) || defined(OS_APPLE)
  19. #define HAS_NATIVE_THREAD_POOL() 1
  20. #else
  21. #define HAS_NATIVE_THREAD_POOL() 0
  22. #endif
  23. #if HAS_NATIVE_THREAD_POOL()
  24. // Under this feature, ThreadPoolImpl will use a ThreadGroup backed by a
  25. // native thread pool implementation. The Windows Thread Pool API and
  26. // libdispatch are used on Windows and macOS/iOS respectively.
  27. extern const BASE_EXPORT Feature kUseNativeThreadPool;
  28. #endif
  29. // Whether threads in the ThreadPool should be reclaimed after being idle for 5
  30. // minutes, instead of 30 seconds.
  31. extern const BASE_EXPORT Feature kUseFiveMinutesThreadReclaimTime;
  32. } // namespace base
  33. #endif // BASE_TASK_TASK_FEATURES_H_