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

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

Issue 1705253002: TaskScheduler [3/9] Task and Sequence (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@s_1_scheduler_lock
Patch Set: Created 4 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_TASK_SCHEDULER_SEQUENCE_H_
6 #define BASE_TASK_SCHEDULER_SEQUENCE_H_
7
8 #include <stddef.h>
9
10 #include <queue>
11
12 #include "base/base_export.h"
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/task_scheduler/scheduler_lock.h"
17 #include "base/task_scheduler/sequence_sort_key.h"
18 #include "base/task_scheduler/task.h"
19 #include "base/task_scheduler/task_traits.h"
20
21 namespace base {
22 namespace internal {
23
24 // A sequence holds tasks that must be executed in posting order. This class is
25 // thread-safe.
26 class BASE_EXPORT Sequence : public RefCountedThreadSafe<Sequence> {
27 public:
28 Sequence();
29
30 // Adds |task| at the end of the sequence's queue. |prev_num_tasks| is set to
31 // the number of tasks that were in the sequence prior to the push.
32 void PushTask(scoped_ptr<Task> task, size_t* prev_num_tasks);
gab 2016/02/18 03:00:46 Return |prev_num_tasks| instead of using an out-pa
fdoray 2016/02/18 14:56:12 Done.
33
34 // Returns the sequence in front of the sequence's queue, if any.
fdoray 2016/02/18 01:46:11 Returns the *task
fdoray 2016/02/18 14:56:12 Done.
35 const Task* PeekTask();
36
37 // Removes the task in front of the sequence's queue. |new_num_tasks| is set
38 // to the number of tasks that are in the sequence right after the pop. This
39 // cannot be called on an empty sequence.
40 void PopTask(size_t* new_num_tasks);
gab 2016/02/18 03:00:46 Same comment here, use return value and try to mak
fdoray 2016/02/18 14:56:12 Done.
41
42 // Returns a sort key to use when inserting the sequence in a priority queue.
gab 2016/02/18 03:00:46 s/sort key/SequenceSortKey/
fdoray 2016/02/18 14:56:12 Done.
43 // This cannot be called on an empty sequence.
44 SequenceSortKey GetSortKey();
45
46 private:
47 friend class RefCountedThreadSafe<Sequence>;
48 ~Sequence();
49
50 // Controls access to all members.
51 SchedulerLock lock_;
52
53 // Queue of tasks to execute.
54 std::queue<scoped_ptr<Task>> queue_;
55
56 // Number of tasks contained in the sequence for each priority.
57 size_t num_tasks_per_priority_[kNumTaskPriorities];
58
59 DISALLOW_COPY_AND_ASSIGN(Sequence);
60 };
61
62 } // namespace internal
63 } // namespace base
64
65 #endif // BASE_TASK_SCHEDULER_SEQUENCE_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/task_scheduler/sequence.cc » ('j') | base/task_scheduler/sequence.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698