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

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

Issue 2781323003: [scheduler] Split lock in TaskQueueImpl. (Closed)
Patch Set: Addressed comments Created 3 years, 8 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 | « no previous file | third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc » ('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 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_TASK_QUEUE_IMPL_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 struct AnyThread { 248 struct AnyThread {
249 AnyThread(TaskQueueManager* task_queue_manager, TimeDomain* time_domain); 249 AnyThread(TaskQueueManager* task_queue_manager, TimeDomain* time_domain);
250 ~AnyThread(); 250 ~AnyThread();
251 251
252 // TaskQueueManager and TimeDomain are maintained in two copies: 252 // TaskQueueManager and TimeDomain are maintained in two copies:
253 // inside AnyThread and inside MainThreadOnly. They can be changed only from 253 // inside AnyThread and inside MainThreadOnly. They can be changed only from
254 // main thread, so it should be locked before accessing from other threads. 254 // main thread, so it should be locked before accessing from other threads.
255 TaskQueueManager* task_queue_manager; 255 TaskQueueManager* task_queue_manager;
256 TimeDomain* time_domain; 256 TimeDomain* time_domain;
257
258 WTF::Deque<Task> immediate_incoming_queue;
259 }; 257 };
260 258
261 struct MainThreadOnly { 259 struct MainThreadOnly {
262 MainThreadOnly(TaskQueueManager* task_queue_manager, 260 MainThreadOnly(TaskQueueManager* task_queue_manager,
263 TaskQueueImpl* task_queue, 261 TaskQueueImpl* task_queue,
264 TimeDomain* time_domain); 262 TimeDomain* time_domain);
265 ~MainThreadOnly(); 263 ~MainThreadOnly();
266 264
267 // Another copy of TaskQueueManager and TimeDomain for lock-free access from 265 // Another copy of TaskQueueManager and TimeDomain for lock-free access from
268 // the main thread. See description inside struct AnyThread for details. 266 // the main thread. See description inside struct AnyThread for details.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 const tracked_objects::Location& posted_from, 310 const tracked_objects::Location& posted_from,
313 base::Closure task, 311 base::Closure task,
314 base::TimeTicks desired_run_time, 312 base::TimeTicks desired_run_time,
315 EnqueueOrder sequence_number, 313 EnqueueOrder sequence_number,
316 bool nestable); 314 bool nestable);
317 315
318 // Extracts all the tasks from the immediate incoming queue and clears it. 316 // Extracts all the tasks from the immediate incoming queue and clears it.
319 // Can be called from any thread. 317 // Can be called from any thread.
320 WTF::Deque<TaskQueueImpl::Task> TakeImmediateIncomingQueue(); 318 WTF::Deque<TaskQueueImpl::Task> TakeImmediateIncomingQueue();
321 319
322 void TraceQueueSize(bool is_locked) const; 320 void TraceQueueSize() const;
323 static void QueueAsValueInto(const WTF::Deque<Task>& queue, 321 static void QueueAsValueInto(const WTF::Deque<Task>& queue,
324 base::trace_event::TracedValue* state); 322 base::trace_event::TracedValue* state);
325 static void QueueAsValueInto(const std::priority_queue<Task>& queue, 323 static void QueueAsValueInto(const std::priority_queue<Task>& queue,
326 base::trace_event::TracedValue* state); 324 base::trace_event::TracedValue* state);
327 static void TaskAsValueInto(const Task& task, 325 static void TaskAsValueInto(const Task& task,
328 base::trace_event::TracedValue* state); 326 base::trace_event::TracedValue* state);
329 327
330 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter); 328 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter);
331 void OnQueueEnabledVoteChanged(bool enabled); 329 void OnQueueEnabledVoteChanged(bool enabled);
332 void EnableOrDisableWithSelector(bool enable); 330 void EnableOrDisableWithSelector(bool enable);
(...skipping 20 matching lines...) Expand all
353 MainThreadOnly main_thread_only_; 351 MainThreadOnly main_thread_only_;
354 MainThreadOnly& main_thread_only() { 352 MainThreadOnly& main_thread_only() {
355 DCHECK(main_thread_checker_.CalledOnValidThread()); 353 DCHECK(main_thread_checker_.CalledOnValidThread());
356 return main_thread_only_; 354 return main_thread_only_;
357 } 355 }
358 const MainThreadOnly& main_thread_only() const { 356 const MainThreadOnly& main_thread_only() const {
359 DCHECK(main_thread_checker_.CalledOnValidThread()); 357 DCHECK(main_thread_checker_.CalledOnValidThread());
360 return main_thread_only_; 358 return main_thread_only_;
361 } 359 }
362 360
361 mutable base::Lock immediate_incoming_queue_lock_;
362 WTF::Deque<Task> immediate_incoming_queue_;
363 WTF::Deque<Task>& immediate_incoming_queue() {
364 immediate_incoming_queue_lock_.AssertAcquired();
365 return immediate_incoming_queue_;
366 }
367 const WTF::Deque<Task>& immediate_incoming_queue() const {
368 immediate_incoming_queue_lock_.AssertAcquired();
369 return immediate_incoming_queue_;
370 }
371
363 const bool should_monitor_quiescence_; 372 const bool should_monitor_quiescence_;
364 const bool should_notify_observers_; 373 const bool should_notify_observers_;
365 const bool should_report_when_execution_blocked_; 374 const bool should_report_when_execution_blocked_;
366 375
367 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); 376 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl);
368 }; 377 };
369 378
370 } // namespace internal 379 } // namespace internal
371 } // namespace scheduler 380 } // namespace scheduler
372 } // namespace blink 381 } // namespace blink
373 382
374 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ 383 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698