Chromium Code Reviews| 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 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 | 14 |
| 15 class TimeDelta; | 15 class TimeDelta; |
| 16 | 16 |
| 17 class BASE_EXPORT SchedulerWorkerPoolParams final { | 17 class BASE_EXPORT SchedulerWorkerPoolParams final { |
| 18 public: | 18 public: |
| 19 enum class IORestriction { | |
| 20 ALLOWED, | |
| 21 DISALLOWED, | |
| 22 }; | |
|
robliao
2016/11/28 14:50:33
ScopedTaskScheduler needs updating.
| |
| 23 | |
| 24 enum class StandbyThreadPolicy { | 19 enum class StandbyThreadPolicy { |
| 25 // Create threads as needed on demand, reclaimed as necessary. | 20 // Create threads as needed on demand, reclaimed as necessary. |
| 26 LAZY, | 21 LAZY, |
| 27 // When possible, keep one idle thread alive on standby, reclaimed as | 22 // When possible, keep one idle thread alive on standby, reclaimed as |
| 28 // necessary. | 23 // necessary. |
| 29 ONE, | 24 ONE, |
| 30 }; | 25 }; |
| 31 | 26 |
| 32 // Construct a scheduler worker pool parameter object. |name| will be used to | 27 // Construct a scheduler worker pool parameter object. |name| will be used to |
| 33 // label the pool's threads ("TaskScheduler" + |name| + index) and histograms | 28 // label the pool's threads ("TaskScheduler" + |name| + index) and histograms |
| 34 // ("TaskScheduler." + histogram name + "." + |name| + extra suffixes). The | 29 // ("TaskScheduler." + histogram name + "." + |name| + extra suffixes). The |
| 35 // pool will contain up to |max_threads|. |priority_hint| is the preferred | 30 // pool will contain up to |max_threads|. |priority_hint| is the preferred |
| 36 // thread priority; the actual thread priority depends on shutdown state and | 31 // thread priority; the actual thread priority depends on shutdown state and |
| 37 // platform capabilities. |io_restriction| indicates whether Tasks on the pool | 32 // platform capabilities. |suggested_reclaim_time| sets a suggestion on when |
| 38 // are allowed to make I/O calls. |suggested_reclaim_time| sets a suggestion | 33 // to reclaim idle threads. The pool is free to ignore this value for |
| 39 // on when to reclaim idle threads. The pool is free to ignore this value for | |
| 40 // performance or correctness reasons. | 34 // performance or correctness reasons. |
| 41 SchedulerWorkerPoolParams(const std::string& name, | 35 SchedulerWorkerPoolParams(const std::string& name, |
| 42 ThreadPriority priority_hint, | 36 ThreadPriority priority_hint, |
| 43 IORestriction io_restriction, | |
| 44 StandbyThreadPolicy standby_thread_policy, | 37 StandbyThreadPolicy standby_thread_policy, |
| 45 int max_threads, | 38 int max_threads, |
| 46 const TimeDelta& suggested_reclaim_time); | 39 const TimeDelta& suggested_reclaim_time); |
| 47 SchedulerWorkerPoolParams(SchedulerWorkerPoolParams&& other); | 40 SchedulerWorkerPoolParams(SchedulerWorkerPoolParams&& other); |
| 48 SchedulerWorkerPoolParams& operator=(SchedulerWorkerPoolParams&& other); | 41 SchedulerWorkerPoolParams& operator=(SchedulerWorkerPoolParams&& other); |
| 49 | 42 |
| 50 const std::string& name() const { return name_; } | 43 const std::string& name() const { return name_; } |
| 51 ThreadPriority priority_hint() const { return priority_hint_; } | 44 ThreadPriority priority_hint() const { return priority_hint_; } |
| 52 IORestriction io_restriction() const { return io_restriction_; } | |
| 53 StandbyThreadPolicy standby_thread_policy() const { | 45 StandbyThreadPolicy standby_thread_policy() const { |
| 54 return standby_thread_policy_; | 46 return standby_thread_policy_; |
| 55 } | 47 } |
| 56 size_t max_threads() const { return max_threads_; } | 48 size_t max_threads() const { return max_threads_; } |
| 57 const TimeDelta& suggested_reclaim_time() const { | 49 const TimeDelta& suggested_reclaim_time() const { |
| 58 return suggested_reclaim_time_; | 50 return suggested_reclaim_time_; |
| 59 } | 51 } |
| 60 | 52 |
| 61 private: | 53 private: |
| 62 std::string name_; | 54 std::string name_; |
| 63 ThreadPriority priority_hint_; | 55 ThreadPriority priority_hint_; |
| 64 IORestriction io_restriction_; | |
| 65 StandbyThreadPolicy standby_thread_policy_; | 56 StandbyThreadPolicy standby_thread_policy_; |
| 66 size_t max_threads_; | 57 size_t max_threads_; |
| 67 TimeDelta suggested_reclaim_time_; | 58 TimeDelta suggested_reclaim_time_; |
| 68 | 59 |
| 69 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolParams); | 60 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolParams); |
| 70 }; | 61 }; |
| 71 | 62 |
| 72 } // namespace base | 63 } // namespace base |
| 73 | 64 |
| 74 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_ | 65 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_ |
| OLD | NEW |