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