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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/time_domain.h

Issue 2653643002: Move has_incoming_immediate_work to the TaskQueueManager (Closed)
Patch Set: Don't try to be quite so clever in TaskQueueManager::ComputeDelayTillNextTask Created 3 years, 11 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 // Migrates |queue| from this time domain to |destination_time_domain|. 85 // Migrates |queue| from this time domain to |destination_time_domain|.
86 // Main-thread only. 86 // Main-thread only.
87 void MigrateQueue(internal::TaskQueueImpl* queue, 87 void MigrateQueue(internal::TaskQueueImpl* queue,
88 TimeDomain* destination_time_domain); 88 TimeDomain* destination_time_domain);
89 89
90 // If there is a scheduled delayed task, |out_task_queue| is set to the queue 90 // If there is a scheduled delayed task, |out_task_queue| is set to the queue
91 // the next task was posted to and it returns true. Returns false otherwise. 91 // the next task was posted to and it returns true. Returns false otherwise.
92 bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const; 92 bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const;
93 93
94 // Adds |queue| to |has_incoming_immediate_work_| which causes 94 // Notifies the time domain observer (if any) that |queue| has incoming
95 // UpdateWorkQueues to reload the immediate work queue if empty. Can be 95 // immediate work.
96 // called from any thread. 96 void OnQueueHasImmediateWork(internal::TaskQueueImpl* queue);
97 // TODO(alexclarke): Move this to the TaskQueueManager.
98 void OnQueueHasIncomingImmediateWork(internal::TaskQueueImpl* queue);
99 97
100 // Schedules a call to TaskQueueImpl::WakeUpForDelayedWork when this 98 // Schedules a call to TaskQueueImpl::WakeUpForDelayedWork when this
101 // TimeDomain reaches |delayed_run_time|. This supersedes any previously 99 // TimeDomain reaches |delayed_run_time|. This supersedes any previously
102 // registered wakeup for |queue|. 100 // registered wakeup for |queue|.
103 void ScheduleDelayedWork(internal::TaskQueueImpl* queue, 101 void ScheduleDelayedWork(internal::TaskQueueImpl* queue,
104 base::TimeTicks delayed_run_time, 102 base::TimeTicks delayed_run_time,
105 base::TimeTicks now); 103 base::TimeTicks now);
106 104
107 // Cancels any scheduled calls to TaskQueueImpl::WakeUpForDelayedWork for 105 // Cancels any scheduled calls to TaskQueueImpl::WakeUpForDelayedWork for
108 // |queue|. 106 // |queue|.
109 void CancelDelayedWork(internal::TaskQueueImpl* queue); 107 void CancelDelayedWork(internal::TaskQueueImpl* queue);
110 108
111 // Registers the |queue|. 109 // Registers the |queue|.
112 void RegisterQueue(internal::TaskQueueImpl* queue); 110 void RegisterQueue(internal::TaskQueueImpl* queue);
113 111
114 // Removes |queue| from all internal data structures. 112 // Removes |queue| from all internal data structures.
115 void UnregisterQueue(internal::TaskQueueImpl* queue); 113 void UnregisterQueue(internal::TaskQueueImpl* queue);
116 114
117 // Updates active queues associated with this TimeDomain.
118 void UpdateWorkQueues(LazyNow* lazy_now);
119
120 // Called by the TaskQueueManager when the TimeDomain is registered. 115 // Called by the TaskQueueManager when the TimeDomain is registered.
121 virtual void OnRegisterWithTaskQueueManager( 116 virtual void OnRegisterWithTaskQueueManager(
122 TaskQueueManager* task_queue_manager) = 0; 117 TaskQueueManager* task_queue_manager) = 0;
123 118
124 // The implementaion will secedule task processing to run with |delay| with 119 // The implementaion will secedule task processing to run with |delay| with
125 // respect to the TimeDomain's time source. Always called on the main thread. 120 // respect to the TimeDomain's time source. Always called on the main thread.
126 // NOTE this is only called by ScheduleDelayedWork if the scheduled runtime 121 // NOTE this is only called by ScheduleDelayedWork if the scheduled runtime
127 // is sooner than any previously sheduled work or if there is no other 122 // is sooner than any previously sheduled work or if there is no other
128 // scheduled work. 123 // scheduled work.
129 virtual void RequestWakeup(base::TimeTicks now, base::TimeDelta delay) = 0; 124 virtual void RequestWakeup(base::TimeTicks now, base::TimeDelta delay) = 0;
(...skipping 30 matching lines...) Expand all
160 DCHECK(queue->heap_handle().IsValid()); 155 DCHECK(queue->heap_handle().IsValid());
161 queue->set_heap_handle(HeapHandle()); 156 queue->set_heap_handle(HeapHandle());
162 157
163 DCHECK_NE(queue->scheduled_time_domain_wakeup(), base::TimeTicks()); 158 DCHECK_NE(queue->scheduled_time_domain_wakeup(), base::TimeTicks());
164 queue->set_scheduled_time_domain_wakeup(base::TimeTicks()); 159 queue->set_scheduled_time_domain_wakeup(base::TimeTicks());
165 } 160 }
166 }; 161 };
167 162
168 IntrusiveHeap<DelayedWakeup> delayed_wakeup_queue_; 163 IntrusiveHeap<DelayedWakeup> delayed_wakeup_queue_;
169 164
170 // This lock guards only |has_incoming_immediate_work_|. It's not expected to 165 Observer* const observer_; // NOT OWNED.
171 // be heavily contended.
172 mutable base::Lock has_incoming_immediate_work_lock_;
173
174 // Set of task queues with newly available work on the incoming queue.
175 // TODO(alexclarke): Move this to the TaskQueueManager.
176 std::set<internal::TaskQueueImpl*> has_incoming_immediate_work_;
177
178 Observer* observer_; // NOT OWNED.
179 166
180 base::ThreadChecker main_thread_checker_; 167 base::ThreadChecker main_thread_checker_;
181 168
182 DISALLOW_COPY_AND_ASSIGN(TimeDomain); 169 DISALLOW_COPY_AND_ASSIGN(TimeDomain);
183 }; 170 };
184 171
185 } // namespace scheduler 172 } // namespace scheduler
186 } // namespace blink 173 } // namespace blink
187 174
188 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ 175 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698