| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_ | 5 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_ |
| 6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_ | 6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
| 12 #include "base/time/time.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 | 15 |
| 15 class TimeDelta; | |
| 16 | |
| 17 class BASE_EXPORT SchedulerWorkerPoolParams final { | 16 class BASE_EXPORT SchedulerWorkerPoolParams final { |
| 18 public: | 17 public: |
| 19 enum class StandbyThreadPolicy { | 18 enum class StandbyThreadPolicy { |
| 20 // Create threads as needed on demand, reclaimed as necessary. | 19 // Create threads as needed on demand, reclaimed as necessary. |
| 21 LAZY, | 20 LAZY, |
| 22 // When possible, keep one idle thread alive on standby, reclaimed as | 21 // When possible, keep one idle thread alive on standby, reclaimed as |
| 23 // necessary. | 22 // necessary. |
| 24 ONE, | 23 ONE, |
| 25 }; | 24 }; |
| 26 | 25 |
| 27 // Construct a scheduler worker pool parameter object. |name| will be used to | 26 // Construct a scheduler worker pool parameter object. |name| will be used to |
| 28 // label the pool's threads ("TaskScheduler" + |name| + index) and histograms | 27 // label the pool's threads ("TaskScheduler" + |name| + index) and histograms |
| 29 // ("TaskScheduler." + histogram name + "." + |name| + extra suffixes). The | 28 // ("TaskScheduler." + histogram name + "." + |name| + extra suffixes). The |
| 30 // pool will contain up to |max_threads|. |priority_hint| is the preferred | 29 // pool will contain up to |max_threads|. |priority_hint| is the preferred |
| 31 // thread priority; the actual thread priority depends on shutdown state and | 30 // thread priority; the actual thread priority depends on shutdown state and |
| 32 // platform capabilities. |suggested_reclaim_time| sets a suggestion on when | 31 // platform capabilities. |suggested_reclaim_time| sets a suggestion on when |
| 33 // to reclaim idle threads. The pool is free to ignore this value for | 32 // to reclaim idle threads. The pool is free to ignore this value for |
| 34 // performance or correctness reasons. | 33 // performance or correctness reasons. |
| 35 SchedulerWorkerPoolParams(const std::string& name, | 34 SchedulerWorkerPoolParams(const std::string& name, |
| 36 ThreadPriority priority_hint, | 35 ThreadPriority priority_hint, |
| 37 StandbyThreadPolicy standby_thread_policy, | 36 StandbyThreadPolicy standby_thread_policy, |
| 38 int max_threads, | 37 int max_threads, |
| 39 const TimeDelta& suggested_reclaim_time); | 38 TimeDelta suggested_reclaim_time); |
| 40 SchedulerWorkerPoolParams(SchedulerWorkerPoolParams&& other); | 39 SchedulerWorkerPoolParams(SchedulerWorkerPoolParams&& other); |
| 41 SchedulerWorkerPoolParams& operator=(SchedulerWorkerPoolParams&& other); | 40 SchedulerWorkerPoolParams& operator=(SchedulerWorkerPoolParams&& other); |
| 42 | 41 |
| 43 const std::string& name() const { return name_; } | 42 const std::string& name() const { return name_; } |
| 44 ThreadPriority priority_hint() const { return priority_hint_; } | 43 ThreadPriority priority_hint() const { return priority_hint_; } |
| 45 StandbyThreadPolicy standby_thread_policy() const { | 44 StandbyThreadPolicy standby_thread_policy() const { |
| 46 return standby_thread_policy_; | 45 return standby_thread_policy_; |
| 47 } | 46 } |
| 48 size_t max_threads() const { return max_threads_; } | 47 size_t max_threads() const { return max_threads_; } |
| 49 const TimeDelta& suggested_reclaim_time() const { | 48 TimeDelta suggested_reclaim_time() const { return suggested_reclaim_time_; } |
| 50 return suggested_reclaim_time_; | |
| 51 } | |
| 52 | 49 |
| 53 private: | 50 private: |
| 54 std::string name_; | 51 std::string name_; |
| 55 ThreadPriority priority_hint_; | 52 ThreadPriority priority_hint_; |
| 56 StandbyThreadPolicy standby_thread_policy_; | 53 StandbyThreadPolicy standby_thread_policy_; |
| 57 size_t max_threads_; | 54 size_t max_threads_; |
| 58 TimeDelta suggested_reclaim_time_; | 55 TimeDelta suggested_reclaim_time_; |
| 59 | 56 |
| 60 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolParams); | 57 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolParams); |
| 61 }; | 58 }; |
| 62 | 59 |
| 63 } // namespace base | 60 } // namespace base |
| 64 | 61 |
| 65 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_ | 62 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_ |
| OLD | NEW |