environment_config.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2017 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_THREAD_POOL_ENVIRONMENT_CONFIG_H_
  5. #define BASE_TASK_THREAD_POOL_ENVIRONMENT_CONFIG_H_
  6. #include <stddef.h>
  7. #include "base/base_export.h"
  8. #include "base/task/task_traits.h"
  9. #include "base/threading/thread.h"
  10. namespace base {
  11. namespace internal {
  12. // TODO(etiennep): This is now specific to
  13. // PooledSingleThreadTaskRunnerManager, move it there.
  14. enum EnvironmentType {
  15. FOREGROUND = 0,
  16. FOREGROUND_BLOCKING,
  17. BACKGROUND,
  18. BACKGROUND_BLOCKING,
  19. ENVIRONMENT_COUNT // Always last.
  20. };
  21. // Order must match the EnvironmentType enum.
  22. struct EnvironmentParams {
  23. // The threads and histograms of this environment will be labeled with
  24. // the thread pool name concatenated to this.
  25. const char* name_suffix;
  26. // Preferred priority for threads in this environment; the actual thread
  27. // priority depends on shutdown state and platform capabilities.
  28. ThreadPriority priority_hint;
  29. };
  30. constexpr EnvironmentParams kEnvironmentParams[] = {
  31. {"Foreground", base::ThreadPriority::NORMAL},
  32. {"ForegroundBlocking", base::ThreadPriority::NORMAL},
  33. {"Background", base::ThreadPriority::BACKGROUND},
  34. {"BackgroundBlocking", base::ThreadPriority::BACKGROUND},
  35. };
  36. // Returns true if this platform supports having WorkerThreads running with a
  37. // background priority.
  38. bool BASE_EXPORT CanUseBackgroundPriorityForWorkerThread();
  39. } // namespace internal
  40. } // namespace base
  41. #endif // BASE_TASK_THREAD_POOL_ENVIRONMENT_CONFIG_H_