Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: base/task_scheduler/scheduler_worker_pool_params.h

Issue 2501763002: Add Thread Standby Policy SchedulerWorkerPoolImpl (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 enum class StandbyThreadPolicy {
25 // Create threads as needed on demand, reclaimed as necessary.
26 LAZY,
27 // When possible, keep one idle thread on standby, reclaimed as necessary.
fdoray 2016/11/15 15:27:02 I think it would be clearer if we re-used the *ali
robliao 2016/11/15 15:57:19 Done.
28 ONE,
29 };
30
24 // Construct a scheduler worker pool parameter object. |name| will be used to 31 // Construct a scheduler worker pool parameter object. |name| will be used to
25 // label the pool's threads ("TaskScheduler" + |name| + index) and histograms 32 // label the pool's threads ("TaskScheduler" + |name| + index) and histograms
26 // ("TaskScheduler." + histogram name + "." + |name| + extra suffixes). The 33 // ("TaskScheduler." + histogram name + "." + |name| + extra suffixes). The
27 // pool will contain up to |max_threads|. |priority_hint| is the preferred 34 // pool will contain up to |max_threads|. |priority_hint| is the preferred
28 // thread priority; the actual thread priority depends on shutdown state and 35 // thread priority; the actual thread priority depends on shutdown state and
29 // platform capabilities. |io_restriction| indicates whether Tasks on the pool 36 // platform capabilities. |io_restriction| indicates whether Tasks on the pool
30 // are allowed to make I/O calls. |suggested_reclaim_time| sets a suggestion 37 // are allowed to make I/O calls. |suggested_reclaim_time| sets a suggestion
31 // on when to reclaim idle threads. The pool is free to ignore this value for 38 // on when to reclaim idle threads. The pool is free to ignore this value for
32 // performance or correctness reasons. 39 // performance or correctness reasons.
33 SchedulerWorkerPoolParams(const std::string& name, 40 SchedulerWorkerPoolParams(const std::string& name,
34 ThreadPriority priority_hint, 41 ThreadPriority priority_hint,
35 IORestriction io_restriction, 42 IORestriction io_restriction,
43 StandbyThreadPolicy standby_thread_policy,
36 int max_threads, 44 int max_threads,
37 const TimeDelta& suggested_reclaim_time); 45 const TimeDelta& suggested_reclaim_time);
38 SchedulerWorkerPoolParams(SchedulerWorkerPoolParams&& other); 46 SchedulerWorkerPoolParams(SchedulerWorkerPoolParams&& other);
39 SchedulerWorkerPoolParams& operator=(SchedulerWorkerPoolParams&& other); 47 SchedulerWorkerPoolParams& operator=(SchedulerWorkerPoolParams&& other);
40 48
41 const std::string& name() const { return name_; } 49 const std::string& name() const { return name_; }
42 ThreadPriority priority_hint() const { return priority_hint_; } 50 ThreadPriority priority_hint() const { return priority_hint_; }
43 IORestriction io_restriction() const { return io_restriction_; } 51 IORestriction io_restriction() const { return io_restriction_; }
52 StandbyThreadPolicy standby_thread_policy() const {
53 return standby_thread_policy_;
54 }
44 size_t max_threads() const { return max_threads_; } 55 size_t max_threads() const { return max_threads_; }
45 const TimeDelta& suggested_reclaim_time() const { 56 const TimeDelta& suggested_reclaim_time() const {
46 return suggested_reclaim_time_; 57 return suggested_reclaim_time_;
47 } 58 }
48 59
49 private: 60 private:
50 std::string name_; 61 std::string name_;
51 ThreadPriority priority_hint_; 62 ThreadPriority priority_hint_;
52 IORestriction io_restriction_; 63 IORestriction io_restriction_;
64 StandbyThreadPolicy standby_thread_policy_;
53 size_t max_threads_; 65 size_t max_threads_;
54 TimeDelta suggested_reclaim_time_; 66 TimeDelta suggested_reclaim_time_;
55 67
56 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolParams); 68 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolParams);
57 }; 69 };
58 70
59 } // namespace base 71 } // namespace base
60 72
61 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_ 73 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_PARAMS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698