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

Side by Side Diff: base/task_scheduler/sequence.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/scheduler_worker.cc ('k') | base/task_scheduler/task_tracker.h » ('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_SEQUENCE_H_ 5 #ifndef BASE_TASK_SCHEDULER_SEQUENCE_H_
6 #define BASE_TASK_SCHEDULER_SEQUENCE_H_ 6 #define BASE_TASK_SCHEDULER_SEQUENCE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <queue> 11 #include <queue>
12 12
13 #include "base/base_export.h" 13 #include "base/base_export.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/sequence_token.h"
16 #include "base/task_scheduler/scheduler_lock.h" 17 #include "base/task_scheduler/scheduler_lock.h"
17 #include "base/task_scheduler/sequence_sort_key.h" 18 #include "base/task_scheduler/sequence_sort_key.h"
18 #include "base/task_scheduler/task.h" 19 #include "base/task_scheduler/task.h"
19 #include "base/task_scheduler/task_traits.h" 20 #include "base/task_scheduler/task_traits.h"
20 21
21 namespace base { 22 namespace base {
22 namespace internal { 23 namespace internal {
23 24
24 // A sequence holds tasks that must be executed in posting order. 25 // A sequence holds tasks that must be executed in posting order.
25 // 26 //
(...skipping 23 matching lines...) Expand all
49 50
50 // Removes the task in front of the sequence's queue. Returns true if the 51 // Removes the task in front of the sequence's queue. Returns true if the
51 // sequence is empty after this operation. Cannot be called on an empty 52 // sequence is empty after this operation. Cannot be called on an empty
52 // sequence. 53 // sequence.
53 bool PopTask(); 54 bool PopTask();
54 55
55 // Returns a SequenceSortKey representing the priority of the sequence. Cannot 56 // Returns a SequenceSortKey representing the priority of the sequence. Cannot
56 // be called on an empty sequence. 57 // be called on an empty sequence.
57 SequenceSortKey GetSortKey() const; 58 SequenceSortKey GetSortKey() const;
58 59
60 // Returns a token that uniquely identifies this Sequence.
61 const SequenceToken& token() const { return token_; }
62
59 private: 63 private:
60 friend class RefCountedThreadSafe<Sequence>; 64 friend class RefCountedThreadSafe<Sequence>;
61 ~Sequence(); 65 ~Sequence();
62 66
67 const SequenceToken token_ = SequenceToken::Create();
68
63 // Synchronizes access to all members. 69 // Synchronizes access to all members.
64 mutable SchedulerLock lock_; 70 mutable SchedulerLock lock_;
65 71
66 // Queue of tasks to execute. 72 // Queue of tasks to execute.
67 std::queue<std::unique_ptr<Task>> queue_; 73 std::queue<std::unique_ptr<Task>> queue_;
68 74
69 // Number of tasks contained in the sequence for each priority. 75 // Number of tasks contained in the sequence for each priority.
70 size_t num_tasks_per_priority_[static_cast<int>(TaskPriority::HIGHEST) + 1] = 76 size_t num_tasks_per_priority_[static_cast<int>(TaskPriority::HIGHEST) + 1] =
71 {}; 77 {};
72 78
73 DISALLOW_COPY_AND_ASSIGN(Sequence); 79 DISALLOW_COPY_AND_ASSIGN(Sequence);
74 }; 80 };
75 81
76 } // namespace internal 82 } // namespace internal
77 } // namespace base 83 } // namespace base
78 84
79 #endif // BASE_TASK_SCHEDULER_SEQUENCE_H_ 85 #endif // BASE_TASK_SCHEDULER_SEQUENCE_H_
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_worker.cc ('k') | base/task_scheduler/task_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698