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

Unified 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, 9 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.h
diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.h b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.h
index 79503356b851cf354ffc12f40d93ef4b862e6fac..06907525f1aee3dfd8fdffafbfc42566f5705734 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.h
+++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.h
@@ -279,6 +279,26 @@ class BLINK_PLATFORM_EXPORT TaskQueueImpl final : public TaskQueue {
base::trace_event::BlameContext* blame_context; // Not owned.
EnqueueOrder current_fence;
base::TimeTicks scheduled_time_domain_wakeup;
+
+ // Number of times any thread lock was acquired from main thread to
+ // allow any thread lock be reentrable from main thread.
+ mutable size_t any_thread_lock_acquired_count;
+ };
+
+ // Helper class to make any_thread_lock reentrable from main thread.
+ // When |acquired_count| pointer is non-null, class uses is to
+ // allow for reentrability. When |acquired_count| is nullptr,
+ // this helper class behaves as a normal base::AutoLock.
+ class AnyThreadAutoLock {
+ public:
+ AnyThreadAutoLock(base::Lock& lock, size_t* acquired_count);
+ AnyThreadAutoLock(AnyThreadAutoLock&& auto_lock) = default;
+ ~AnyThreadAutoLock();
+
+ private:
+ base::Lock& lock_;
+ size_t* acquired_count_;
+ DISALLOW_COPY_AND_ASSIGN(AnyThreadAutoLock);
};
~TaskQueueImpl() override;
@@ -330,6 +350,8 @@ class BLINK_PLATFORM_EXPORT TaskQueueImpl final : public TaskQueue {
void OnQueueEnabledVoteChanged(bool enabled);
void EnableOrDisableWithSelector(bool enable);
+ AnyThreadAutoLock AcquireAnyThreadLock() const;
+
const base::PlatformThreadId thread_id_;
mutable base::Lock any_thread_lock_;
« 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