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

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

Issue 2777063010: [scheduler] Make any thread lock in TaskQueueImpl reentrable. (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
« 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 std::unique_ptr<WorkQueue> immediate_work_queue; 272 std::unique_ptr<WorkQueue> immediate_work_queue;
273 std::priority_queue<Task> delayed_incoming_queue; 273 std::priority_queue<Task> delayed_incoming_queue;
274 base::ObserverList<base::MessageLoop::TaskObserver> task_observers; 274 base::ObserverList<base::MessageLoop::TaskObserver> task_observers;
275 size_t set_index; 275 size_t set_index;
276 HeapHandle heap_handle; 276 HeapHandle heap_handle;
277 int is_enabled_refcount; 277 int is_enabled_refcount;
278 int voter_refcount; 278 int voter_refcount;
279 base::trace_event::BlameContext* blame_context; // Not owned. 279 base::trace_event::BlameContext* blame_context; // Not owned.
280 EnqueueOrder current_fence; 280 EnqueueOrder current_fence;
281 base::TimeTicks scheduled_time_domain_wakeup; 281 base::TimeTicks scheduled_time_domain_wakeup;
282
283 // Number of times any thread lock was acquired from main thread to
284 // allow any thread lock be reentrable from main thread.
285 mutable size_t any_thread_lock_acquired_count;
286 };
287
288 // Helper class to make any_thread_lock reentrable from main thread.
289 // When |acquired_count| pointer is non-null, class uses is to
290 // allow for reentrability. When |acquired_count| is nullptr,
291 // this helper class behaves as a normal base::AutoLock.
292 class AnyThreadAutoLock {
293 public:
294 AnyThreadAutoLock(base::Lock& lock, size_t* acquired_count);
295 AnyThreadAutoLock(AnyThreadAutoLock&& auto_lock) = default;
296 ~AnyThreadAutoLock();
297
298 private:
299 base::Lock& lock_;
300 size_t* acquired_count_;
301 DISALLOW_COPY_AND_ASSIGN(AnyThreadAutoLock);
282 }; 302 };
283 303
284 ~TaskQueueImpl() override; 304 ~TaskQueueImpl() override;
285 305
286 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here, 306 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here,
287 const base::Closure& task, 307 const base::Closure& task,
288 TaskType task_type); 308 TaskType task_type);
289 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, 309 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here,
290 const base::Closure& task, 310 const base::Closure& task,
291 base::TimeDelta delay, 311 base::TimeDelta delay,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 base::trace_event::TracedValue* state); 343 base::trace_event::TracedValue* state);
324 static void QueueAsValueInto(const std::priority_queue<Task>& queue, 344 static void QueueAsValueInto(const std::priority_queue<Task>& queue,
325 base::trace_event::TracedValue* state); 345 base::trace_event::TracedValue* state);
326 static void TaskAsValueInto(const Task& task, 346 static void TaskAsValueInto(const Task& task,
327 base::trace_event::TracedValue* state); 347 base::trace_event::TracedValue* state);
328 348
329 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter); 349 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter);
330 void OnQueueEnabledVoteChanged(bool enabled); 350 void OnQueueEnabledVoteChanged(bool enabled);
331 void EnableOrDisableWithSelector(bool enable); 351 void EnableOrDisableWithSelector(bool enable);
332 352
353 AnyThreadAutoLock AcquireAnyThreadLock() const;
354
333 const base::PlatformThreadId thread_id_; 355 const base::PlatformThreadId thread_id_;
334 356
335 mutable base::Lock any_thread_lock_; 357 mutable base::Lock any_thread_lock_;
336 AnyThread any_thread_; 358 AnyThread any_thread_;
337 struct AnyThread& any_thread() { 359 struct AnyThread& any_thread() {
338 any_thread_lock_.AssertAcquired(); 360 any_thread_lock_.AssertAcquired();
339 return any_thread_; 361 return any_thread_;
340 } 362 }
341 const struct AnyThread& any_thread() const { 363 const struct AnyThread& any_thread() const {
342 any_thread_lock_.AssertAcquired(); 364 any_thread_lock_.AssertAcquired();
(...skipping 21 matching lines...) Expand all
364 const bool should_report_when_execution_blocked_; 386 const bool should_report_when_execution_blocked_;
365 387
366 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); 388 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl);
367 }; 389 };
368 390
369 } // namespace internal 391 } // namespace internal
370 } // namespace scheduler 392 } // namespace scheduler
371 } // namespace blink 393 } // namespace blink
372 394
373 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ 395 #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