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

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

Issue 2172713003: TaskScheduler: Set the current SequenceToken when a Task runs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@token
Patch Set: rebase + CR robliao #4 (padding) Created 4 years, 4 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/sequence.h ('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/base_export.h" 10 #include "base/base_export.h"
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/metrics/histogram_base.h" 13 #include "base/metrics/histogram_base.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "base/task_scheduler/scheduler_lock.h" 15 #include "base/task_scheduler/scheduler_lock.h"
16 #include "base/task_scheduler/sequence.h"
16 #include "base/task_scheduler/task.h" 17 #include "base/task_scheduler/task.h"
17 #include "base/task_scheduler/task_traits.h" 18 #include "base/task_scheduler/task_traits.h"
18 19
19 namespace base { 20 namespace base {
20 namespace internal { 21 namespace internal {
21 22
22 // All tasks go through the scheduler's TaskTracker when they are posted and 23 // All tasks go through the scheduler's TaskTracker when they are posted and
23 // when they are executed. The TaskTracker enforces shutdown semantics and takes 24 // when they are executed. The TaskTracker enforces shutdown semantics and takes
24 // care of tracing and profiling. This class is thread-safe. 25 // care of tracing and profiling. This class is thread-safe.
25 class BASE_EXPORT TaskTracker { 26 class BASE_EXPORT TaskTracker {
26 public: 27 public:
27 TaskTracker(); 28 TaskTracker();
28 ~TaskTracker(); 29 ~TaskTracker();
29 30
30 // Synchronously shuts down the scheduler. Once this is called, only tasks 31 // Synchronously shuts down the scheduler. Once this is called, only tasks
31 // posted with the BLOCK_SHUTDOWN behavior will be run. Returns when: 32 // posted with the BLOCK_SHUTDOWN behavior will be run. Returns when:
32 // - All SKIP_ON_SHUTDOWN tasks that were already running have completed their 33 // - All SKIP_ON_SHUTDOWN tasks that were already running have completed their
33 // execution. 34 // execution.
34 // - All posted BLOCK_SHUTDOWN tasks have completed their execution. 35 // - All posted BLOCK_SHUTDOWN tasks have completed their execution.
35 // CONTINUE_ON_SHUTDOWN tasks still may be running after Shutdown returns. 36 // CONTINUE_ON_SHUTDOWN tasks still may be running after Shutdown returns.
36 // This can only be called once. 37 // This can only be called once.
37 void Shutdown(); 38 void Shutdown();
38 39
39 // Informs this TaskTracker that |task| is about to be posted. Returns true if 40 // Informs this TaskTracker that |task| is about to be posted. Returns true if
40 // this operation is allowed (|task| should be posted if-and-only-if it is). 41 // this operation is allowed (|task| should be posted if-and-only-if it is).
41 bool WillPostTask(const Task* task); 42 bool WillPostTask(const Task* task);
42 43
43 // Runs |task| unless the current shutdown state prevents that. WillPostTask() 44 // Runs the next Task in |sequence| unless the current shutdown state prevents
44 // must have allowed |task| to be posted. 45 // that. WillPostTask() must have allowed the Task to be posted.
45 void RunTask(const Task* task); 46 void RunNextTaskInSequence(const Sequence* sequence);
46 47
47 // Returns true once shutdown has started (Shutdown() has been called but 48 // Returns true once shutdown has started (Shutdown() has been called but
48 // might not have returned). 49 // might not have returned).
49 bool HasShutdownStarted() const; 50 bool HasShutdownStarted() const;
50 51
51 // Returns true if shutdown has completed (Shutdown() has returned). 52 // Returns true if shutdown has completed (Shutdown() has returned).
52 bool IsShutdownComplete() const; 53 bool IsShutdownComplete() const;
53 54
54 // Causes HasShutdownStarted() to return true. Unlike when Shutdown() returns, 55 // Causes HasShutdownStarted() to return true. Unlike when Shutdown() returns,
55 // IsShutdownComplete() won't return true after this returns. Shutdown() 56 // IsShutdownComplete() won't return true after this returns. Shutdown()
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // Number of BLOCK_SHUTDOWN tasks posted during shutdown. 93 // Number of BLOCK_SHUTDOWN tasks posted during shutdown.
93 HistogramBase::Sample num_block_shutdown_tasks_posted_during_shutdown_ = 0; 94 HistogramBase::Sample num_block_shutdown_tasks_posted_during_shutdown_ = 0;
94 95
95 DISALLOW_COPY_AND_ASSIGN(TaskTracker); 96 DISALLOW_COPY_AND_ASSIGN(TaskTracker);
96 }; 97 };
97 98
98 } // namespace internal 99 } // namespace internal
99 } // namespace base 100 } // namespace base
100 101
101 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_H_ 102 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_H_
OLDNEW
« no previous file with comments | « base/task_scheduler/sequence.h ('k') | base/task_scheduler/task_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698