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

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

Powered by Google App Engine
This is Rietveld 408576698