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

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

Issue 2427963002: Support FileDescriptorWatcher in TaskScheduler. (Closed)
Patch Set: CR robliao #23 Created 4 years, 2 months 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_TASK_SCHEDULER_IMPL_H_ 5 #ifndef BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ 6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/base_export.h" 14 #include "base/base_export.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/synchronization/atomic_flag.h" 19 #include "base/synchronization/atomic_flag.h"
20 #include "base/task_runner.h" 20 #include "base/task_runner.h"
21 #include "base/task_scheduler/delayed_task_manager.h"
22 #include "base/task_scheduler/scheduler_worker_pool_impl.h" 21 #include "base/task_scheduler/scheduler_worker_pool_impl.h"
23 #include "base/task_scheduler/sequence.h" 22 #include "base/task_scheduler/sequence.h"
24 #include "base/task_scheduler/task_scheduler.h" 23 #include "base/task_scheduler/task_scheduler.h"
25 #include "base/task_scheduler/task_tracker.h"
26 #include "base/task_scheduler/task_traits.h" 24 #include "base/task_scheduler/task_traits.h"
27 #include "base/threading/thread.h" 25 #include "base/threading/thread.h"
28 26
29 namespace base { 27 namespace base {
30 28
31 class SchedulerWorkerPoolParams; 29 class SchedulerWorkerPoolParams;
32 30
33 namespace internal { 31 namespace internal {
34 32
33 class DelayedTaskManager;
35 class SchedulerServiceThread; 34 class SchedulerServiceThread;
35 class TaskTracker;
36 36
37 // Default TaskScheduler implementation. This class is thread-safe. 37 // Default TaskScheduler implementation. This class is thread-safe.
38 class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler { 38 class BASE_EXPORT TaskSchedulerImpl : public TaskScheduler {
39 public: 39 public:
40 // Creates and returns an initialized TaskSchedulerImpl. CHECKs on failure. 40 // Creates and returns an initialized TaskSchedulerImpl. CHECKs on failure.
41 // |worker_pool_params_vector| describes the worker pools to create. 41 // |worker_pool_params_vector| describes the worker pools to create.
42 // |worker_pool_index_for_traits_callback| returns the index in |worker_pools| 42 // |worker_pool_index_for_traits_callback| returns the index in |worker_pools|
43 // of the worker pool in which a task with given traits should run. 43 // of the worker pool in which a task with given traits should run.
44 static std::unique_ptr<TaskSchedulerImpl> Create( 44 static std::unique_ptr<TaskSchedulerImpl> Create(
45 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector, 45 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector,
(...skipping 26 matching lines...) Expand all
72 void Initialize( 72 void Initialize(
73 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector); 73 const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector);
74 74
75 // Returns the worker pool that runs Tasks with |traits|. 75 // Returns the worker pool that runs Tasks with |traits|.
76 SchedulerWorkerPool* GetWorkerPoolForTraits(const TaskTraits& traits); 76 SchedulerWorkerPool* GetWorkerPoolForTraits(const TaskTraits& traits);
77 77
78 // Callback invoked when a non-single-thread |sequence| isn't empty after a 78 // Callback invoked when a non-single-thread |sequence| isn't empty after a
79 // worker pops a Task from it. 79 // worker pops a Task from it.
80 void ReEnqueueSequenceCallback(scoped_refptr<Sequence> sequence); 80 void ReEnqueueSequenceCallback(scoped_refptr<Sequence> sequence);
81 81
82 TaskTracker task_tracker_;
83 Thread service_thread_; 82 Thread service_thread_;
83 std::unique_ptr<TaskTracker> task_tracker_;
84 std::unique_ptr<DelayedTaskManager> delayed_task_manager_; 84 std::unique_ptr<DelayedTaskManager> delayed_task_manager_;
85 const WorkerPoolIndexForTraitsCallback worker_pool_index_for_traits_callback_; 85 const WorkerPoolIndexForTraitsCallback worker_pool_index_for_traits_callback_;
86 std::vector<std::unique_ptr<SchedulerWorkerPoolImpl>> worker_pools_; 86 std::vector<std::unique_ptr<SchedulerWorkerPoolImpl>> worker_pools_;
87 87
88 #if DCHECK_IS_ON() 88 #if DCHECK_IS_ON()
89 // Set once JoinForTesting() has returned. 89 // Set once JoinForTesting() has returned.
90 AtomicFlag join_for_testing_returned_; 90 AtomicFlag join_for_testing_returned_;
91 #endif 91 #endif
92 92
93 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl); 93 DISALLOW_COPY_AND_ASSIGN(TaskSchedulerImpl);
94 }; 94 };
95 95
96 } // namespace internal 96 } // namespace internal
97 } // namespace base 97 } // namespace base
98 98
99 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_ 99 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698