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