| 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 { | 19 enum class IORestriction { |
| 20 ALLOWED, | 20 ALLOWED, |
| 21 DISALLOWED, | 21 DISALLOWED, |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 // Construct a scheduler worker pool parameter object that instructs a | 24 // Construct a scheduler worker pool parameter object that instructs a |
| 25 // scheduler worker pool to use the label |name| and create up to | 25 // scheduler worker pool to use the label |name| and create up to |
| 26 // |max_threads| threads of priority |thread_priority|. |io_restriction| | 26 // |max_threads| threads. |priority_hint| is the preferred thread priority; |
| 27 // indicates whether Tasks on the scheduler worker pool are allowed to make | 27 // the actual thread priority depends on shutdown state and platform |
| 28 // I/O calls. |suggested_reclaim_time| sets a suggestion on when to reclaim | 28 // capabilities. |io_restriction| indicates whether Tasks on the scheduler |
| 29 // idle threads. The worker pool is free to ignore this value for performance | 29 // worker pool are allowed to make I/O calls. |suggested_reclaim_time| sets a |
| 30 // or correctness reasons. | 30 // suggestion on when to reclaim idle threads. The worker pool is free to |
| 31 SchedulerWorkerPoolParams( | 31 // ignore this value for performance or correctness reasons. |
| 32 const std::string& name, | 32 SchedulerWorkerPoolParams(const std::string& name, |
| 33 ThreadPriority thread_priority, | 33 ThreadPriority priority_hint, |
| 34 IORestriction io_restriction, | 34 IORestriction io_restriction, |
| 35 int max_threads, | 35 int max_threads, |
| 36 const TimeDelta& suggested_reclaim_time); | 36 const TimeDelta& suggested_reclaim_time); |
| 37 SchedulerWorkerPoolParams(SchedulerWorkerPoolParams&& other); | 37 SchedulerWorkerPoolParams(SchedulerWorkerPoolParams&& other); |
| 38 SchedulerWorkerPoolParams& operator=(SchedulerWorkerPoolParams&& other); | 38 SchedulerWorkerPoolParams& operator=(SchedulerWorkerPoolParams&& other); |
| 39 | 39 |
| 40 // Name of the pool. Used to label the pool's threads. | 40 // Name of the pool. Used to label the pool's threads. |
| 41 const std::string& name() const { return name_; } | 41 const std::string& name() const { return name_; } |
| 42 | 42 |
| 43 // Priority of the pool's threads. | 43 // Preferred priority for the pool's threads. |
| 44 ThreadPriority thread_priority() const { return thread_priority_; } | 44 ThreadPriority priority_hint() const { return priority_hint_; } |
| 45 | 45 |
| 46 // Whether I/O is allowed in the pool. | 46 // Whether I/O is allowed in the pool. |
| 47 IORestriction io_restriction() const { return io_restriction_; } | 47 IORestriction io_restriction() const { return io_restriction_; } |
| 48 | 48 |
| 49 // Maximum number of threads in the pool. | 49 // Maximum number of threads in the pool. |
| 50 size_t max_threads() const { return max_threads_; } | 50 size_t max_threads() const { return max_threads_; } |
| 51 | 51 |
| 52 // Suggested reclaim time for threads in the worker pool. | 52 // Suggested reclaim time for threads in the worker pool. |
| 53 const TimeDelta& suggested_reclaim_time() const { | 53 const TimeDelta& suggested_reclaim_time() const { |
| 54 return suggested_reclaim_time_; | 54 return suggested_reclaim_time_; |
| 55 } | 55 } |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 std::string name_; | 58 std::string name_; |
| 59 ThreadPriority thread_priority_; | 59 ThreadPriority priority_hint_; |
| 60 IORestriction io_restriction_; | 60 IORestriction io_restriction_; |
| 61 size_t max_threads_; | 61 size_t max_threads_; |
| 62 TimeDelta suggested_reclaim_time_; | 62 TimeDelta suggested_reclaim_time_; |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolParams); | 64 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolParams); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace base | 67 } // namespace base |
| 68 | 68 |
| 69 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_ | 69 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_ |
| OLD | NEW |