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

Side by Side Diff: components/scheduler/base/work_queue_sets.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
« no previous file with comments | « components/scheduler/base/work_queue.cc ('k') | components/scheduler/base/work_queue_sets.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 COMPONENTS_SCHEDULER_BASE_WORK_QUEUE_SETS_H_
6 #define COMPONENTS_SCHEDULER_BASE_WORK_QUEUE_SETS_H_
7
8 #include <stddef.h>
9
10 #include <map>
11 #include <vector>
12
13 #include "base/logging.h"
14 #include "base/macros.h"
15 #include "base/trace_event/trace_event_argument.h"
16 #include "components/scheduler/base/task_queue_impl.h"
17 #include "components/scheduler/scheduler_export.h"
18
19 namespace scheduler {
20 namespace internal {
21 class TaskQueueImpl;
22
23 class SCHEDULER_EXPORT WorkQueueSets {
24 public:
25 WorkQueueSets(size_t num_sets, const char* name);
26 ~WorkQueueSets();
27
28 // O(log num queues)
29 void AddQueue(WorkQueue* queue, size_t set_index);
30
31 // O(log num queues)
32 void RemoveQueue(WorkQueue* work_queue);
33
34 // O(log num queues)
35 void ChangeSetIndex(WorkQueue* queue, size_t set_index);
36
37 // O(log num queues)
38 void OnPushQueue(WorkQueue* work_queue);
39
40 // If empty it's O(1) amortized, otherwise it's O(log num queues)
41 void OnPopQueue(WorkQueue* work_queue);
42
43 // O(1)
44 bool GetOldestQueueInSet(size_t set_index, WorkQueue** out_work_queue) const;
45
46 // O(1)
47 bool IsSetEmpty(size_t set_index) const;
48
49 #if DCHECK_IS_ON() || !defined(NDEBUG)
50 // Note this iterates over everything in |enqueue_order_to_work_queue_maps_|.
51 // It's intended for use with DCHECKS and for testing
52 bool ContainsWorkQueueForTest(const WorkQueue* queue) const;
53 #endif
54
55 const char* name() const { return name_; }
56
57 private:
58 typedef std::map<EnqueueOrder, WorkQueue*> EnqueueOrderToWorkQueueMap;
59 std::vector<EnqueueOrderToWorkQueueMap> enqueue_order_to_work_queue_maps_;
60 const char* name_;
61
62 DISALLOW_COPY_AND_ASSIGN(WorkQueueSets);
63 };
64
65 } // namespace internal
66 } // namespace scheduler
67
68 #endif // COMPONENTS_SCHEDULER_BASE_WORK_QUEUE_SETS_H_
OLDNEW
« no previous file with comments | « components/scheduler/base/work_queue.cc ('k') | components/scheduler/base/work_queue_sets.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698