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

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

Issue 2427963002: Support FileDescriptorWatcher in TaskScheduler. (Closed)
Patch Set: nacl 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
« no previous file with comments | « base/task_scheduler/task_scheduler_impl.cc ('k') | base/task_scheduler/task_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_TRACKER_H_ 5 #ifndef BASE_TASK_SCHEDULER_TASK_TRACKER_H_
6 #define BASE_TASK_SCHEDULER_TASK_TRACKER_H_ 6 #define BASE_TASK_SCHEDULER_TASK_TRACKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
11 #include "base/base_export.h" 11 #include "base/base_export.h"
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/metrics/histogram_base.h" 14 #include "base/metrics/histogram_base.h"
15 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
16 #include "base/task_scheduler/scheduler_lock.h" 16 #include "base/task_scheduler/scheduler_lock.h"
17 #include "base/task_scheduler/sequence.h" 17 #include "base/task_scheduler/sequence.h"
18 #include "base/task_scheduler/task.h" 18 #include "base/task_scheduler/task.h"
19 #include "base/task_scheduler/task_traits.h" 19 #include "base/task_scheduler/task_traits.h"
20 #include "build/build_config.h"
20 21
21 namespace base { 22 namespace base {
22 23
23 class ConditionVariable; 24 class ConditionVariable;
25 class MessageLoopForIO;
24 class SequenceToken; 26 class SequenceToken;
25 27
26 namespace internal { 28 namespace internal {
27 29
28 // All tasks go through the scheduler's TaskTracker when they are posted and 30 // All tasks go through the scheduler's TaskTracker when they are posted and
29 // when they are executed. The TaskTracker enforces shutdown semantics and takes 31 // when they are executed. The TaskTracker sets up the environment to run a
30 // care of tracing and profiling. This class is thread-safe. 32 // task, enforces shutdown semantics and takes care of tracing and profiling.
33 // This class is thread-safe.
31 class BASE_EXPORT TaskTracker { 34 class BASE_EXPORT TaskTracker {
32 public: 35 public:
33 TaskTracker(); 36 // |watch_file_descriptor_message_loop| is used to initialize a
37 // FileDescriptorWatcher in the scope in which a Task runs.
38 TaskTracker(
39 #if defined(OS_POSIX) && !defined(OS_NACL_SFI)
40 MessageLoopForIO* watch_file_descriptor_message_loop
gab 2016/10/18 14:40:43 It feels a bit intrusive to add this directly to T
fdoray 2016/10/18 15:30:43 We already register TaskRunner handles from TaskTr
41 #endif
42 );
34 ~TaskTracker(); 43 ~TaskTracker();
35 44
36 // Synchronously shuts down the scheduler. Once this is called, only tasks 45 // Synchronously shuts down the scheduler. Once this is called, only tasks
37 // posted with the BLOCK_SHUTDOWN behavior will be run. Returns when: 46 // posted with the BLOCK_SHUTDOWN behavior will be run. Returns when:
38 // - All SKIP_ON_SHUTDOWN tasks that were already running have completed their 47 // - All SKIP_ON_SHUTDOWN tasks that were already running have completed their
39 // execution. 48 // execution.
40 // - All posted BLOCK_SHUTDOWN tasks have completed their execution. 49 // - All posted BLOCK_SHUTDOWN tasks have completed their execution.
41 // CONTINUE_ON_SHUTDOWN tasks still may be running after Shutdown returns. 50 // CONTINUE_ON_SHUTDOWN tasks still may be running after Shutdown returns.
42 // This can only be called once. 51 // This can only be called once.
43 void Shutdown(); 52 void Shutdown();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // Synchronizes access to shutdown related members below. 133 // Synchronizes access to shutdown related members below.
125 mutable SchedulerLock shutdown_lock_; 134 mutable SchedulerLock shutdown_lock_;
126 135
127 // Event instantiated when shutdown starts and signaled when shutdown 136 // Event instantiated when shutdown starts and signaled when shutdown
128 // completes. 137 // completes.
129 std::unique_ptr<WaitableEvent> shutdown_event_; 138 std::unique_ptr<WaitableEvent> shutdown_event_;
130 139
131 // Number of BLOCK_SHUTDOWN tasks posted during shutdown. 140 // Number of BLOCK_SHUTDOWN tasks posted during shutdown.
132 HistogramBase::Sample num_block_shutdown_tasks_posted_during_shutdown_ = 0; 141 HistogramBase::Sample num_block_shutdown_tasks_posted_during_shutdown_ = 0;
133 142
143 #if defined(OS_POSIX) && !defined(OS_NACL_SFI)
144 MessageLoopForIO* const watch_file_descriptor_message_loop_;
145 #endif
146
134 DISALLOW_COPY_AND_ASSIGN(TaskTracker); 147 DISALLOW_COPY_AND_ASSIGN(TaskTracker);
135 }; 148 };
136 149
137 } // namespace internal 150 } // namespace internal
138 } // namespace base 151 } // namespace base
139 152
140 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_H_ 153 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_H_
OLDNEW
« no previous file with comments | « base/task_scheduler/task_scheduler_impl.cc ('k') | base/task_scheduler/task_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698