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

Side by Side Diff: components/scheduler/base/work_queue.h

Issue 2118903002: scheduler: Move the Blink scheduler into Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased 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
OLDNEW
(Empty)
1 // Copyright 2015 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 CONTENT_RENDERER_SCHEDULER_BASE_WORK_QUEUE_H_
6 #define CONTENT_RENDERER_SCHEDULER_BASE_WORK_QUEUE_H_
7
8 #include <stddef.h>
9
10 #include <set>
11
12 #include "base/trace_event/trace_event.h"
13 #include "base/trace_event/trace_event_argument.h"
14 #include "components/scheduler/base/enqueue_order.h"
15 #include "components/scheduler/base/task_queue_impl.h"
16 #include "components/scheduler/scheduler_export.h"
17
18 namespace scheduler {
19 namespace internal {
20 class WorkQueueSets;
21
22 class SCHEDULER_EXPORT WorkQueue {
23 public:
24 WorkQueue(TaskQueueImpl* task_queue, const char* name);
25 ~WorkQueue();
26
27 // Associates this work queue with the given work queue sets. This must be
28 // called before any tasks can be inserted into this work queue.
29 void AssignToWorkQueueSets(WorkQueueSets* work_queue_sets);
30
31 // Assigns the current set index.
32 void AssignSetIndex(size_t work_queue_set_index);
33
34 void AsValueInto(base::trace_event::TracedValue* state) const;
35
36 // Clears the |work_queue_|.
37 void Clear();
38
39 // returns true if the |work_queue_| is empty.
40 bool Empty() const { return work_queue_.empty(); }
41
42 // If the |work_queue_| isn't empty, |enqueue_order| gets set to the enqueue
43 // order of the front task and the function returns true. Otherwise the
44 // function returns false.
45 bool GetFrontTaskEnqueueOrder(EnqueueOrder* enqueue_order) const;
46
47 // Returns the first task in this queue or null if the queue is empty.
48 const TaskQueueImpl::Task* GetFrontTask() const;
49
50 // Pushes the task onto the |work_queue_| and informs the WorkQueueSets if
51 // the head changed.
52 void Push(TaskQueueImpl::Task task);
53
54 // Pushes the task onto the |work_queue_|, sets the |enqueue_order| and
55 // informs the WorkQueueSets if the head changed.
56 void PushAndSetEnqueueOrder(TaskQueueImpl::Task task,
57 EnqueueOrder enqueue_order);
58
59 // Swap the |work_queue_| with |incoming_queue| and informs the
60 // WorkQueueSets if the head changed. Assumes |task_queue_->any_thread_lock_|
61 // is locked.
62 void SwapLocked(std::queue<TaskQueueImpl::Task>& incoming_queue);
63
64 size_t Size() const { return work_queue_.size(); }
65
66 // Pulls a task off the |work_queue_| and informs the WorkQueueSets.
67 TaskQueueImpl::Task TakeTaskFromWorkQueue();
68
69 const char* name() const { return name_; }
70
71 TaskQueueImpl* task_queue() const { return task_queue_; }
72
73 WorkQueueSets* work_queue_sets() const { return work_queue_sets_; }
74
75 size_t work_queue_set_index() const { return work_queue_set_index_; }
76
77 // Test support function. This should not be used in production code.
78 void PopTaskForTest();
79
80 // Returns true if the front task in this queue has an older enqueue order
81 // than the front task of |other_queue|. Both queue are assumed to be
82 // non-empty.
83 bool ShouldRunBefore(const WorkQueue* other_queue) const;
84
85 private:
86 std::queue<TaskQueueImpl::Task> work_queue_;
87 WorkQueueSets* work_queue_sets_; // NOT OWNED.
88 TaskQueueImpl* task_queue_; // NOT OWNED.
89 size_t work_queue_set_index_;
90 const char* name_;
91
92 DISALLOW_COPY_AND_ASSIGN(WorkQueue);
93 };
94
95 } // namespace internal
96 } // namespace scheduler
97
98 #endif // CONTENT_RENDERER_SCHEDULER_BASE_WORK_QUEUE_H_
OLDNEW
« no previous file with comments | « components/scheduler/base/virtual_time_domain.cc ('k') | components/scheduler/base/work_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698