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

Side by Side Diff: Source/platform/scheduler/Scheduler.h

Issue 621363002: scheduler: Post high priority tasks directly to the message loop (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tests. Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 Scheduler_h 5 #ifndef Scheduler_h
6 #define Scheduler_h 6 #define Scheduler_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/scheduler/TracedTask.h" 9 #include "platform/scheduler/TracedTask.h"
10 #include "wtf/DoubleBufferedDeque.h" 10 #include "wtf/DoubleBufferedDeque.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 enum SchedulerPolicy { 68 enum SchedulerPolicy {
69 Normal, 69 Normal,
70 CompositorPriority, 70 CompositorPriority,
71 }; 71 };
72 72
73 Scheduler(); 73 Scheduler();
74 virtual ~Scheduler(); 74 virtual ~Scheduler();
75 75
76 void scheduleIdleTask(const TraceLocation&, const IdleTask&); 76 void scheduleIdleTask(const TraceLocation&, const IdleTask&);
77 void postHighPriorityTaskInternal(const TraceLocation&, const Task&, const c har* traceName); 77 void postHighPriorityTaskInternal(const TraceLocation&, const Task&, const c har* traceName);
78 void didRunHighPriorityTask();
78 79
79 static void sharedTimerAdapter(); 80 static void sharedTimerAdapter();
80 81
81 // Start of main thread only members ----------------------------------- 82 // Start of main thread only members -----------------------------------
82 83
83 // Only does work in CompositorPriority mode. Returns true if any work was d one. 84 // Only does work in CompositorPriority mode. Returns true if any work was d one.
84 bool runPendingHighPriorityTasksIfInCompositorPriority(); 85 bool runPendingHighPriorityTasksIfInCompositorPriority();
85 86
86 // Returns true if any work was done. 87 // Returns true if any work was done.
87 bool swapQueuesAndRunPendingTasks();
88
89 void swapQueuesRunPendingTasksAndAllowHighPriorityTaskRunnerPosting();
90
91 // Returns true if any work was done.
92 bool executeHighPriorityTasks(Deque<TracedTask>&); 88 bool executeHighPriorityTasks(Deque<TracedTask>&);
93 89
94 // Return the current SchedulerPolicy. 90 // Return the current SchedulerPolicy.
95 SchedulerPolicy schedulerPolicy() const; 91 SchedulerPolicy schedulerPolicy() const;
96 92
97 void maybeEnterNormalSchedulerPolicy(); 93 void updatePolicy();
98
99 // Must be called while m_pendingTasksMutex is locked.
100 void maybePostMainThreadPendingHighPriorityTaskRunner();
101 94
102 void tickSharedTimer(); 95 void tickSharedTimer();
103 96
104 void (*m_sharedTimerFunction)(); 97 void (*m_sharedTimerFunction)();
105 98
106 // End of main thread only members ------------------------------------- 99 // End of main thread only members -------------------------------------
107 100
108 bool hasPendingHighPriorityWork() const; 101 bool hasPendingHighPriorityWork() const;
109 102
110 void enterSchedulerPolicyLocked(SchedulerPolicy); 103 void enterSchedulerPolicyLocked(SchedulerPolicy);
111 104
112 void enterSchedulerPolicy(SchedulerPolicy); 105 void enterSchedulerPolicy(SchedulerPolicy);
113 106
114 static Scheduler* s_sharedScheduler; 107 static Scheduler* s_sharedScheduler;
115 108
116 WebThread* m_mainThread; 109 WebThread* m_mainThread;
117 110
118 // This mutex protects calls to the pending task queue, m_highPriorityTaskRu nnerPosted and 111 // This mutex protects m_compositorPriorityPolicyEndTimeSeconds.
119 // m_compositorPriorityPolicyEndTimeSeconds.
120 Mutex m_pendingTasksMutex; 112 Mutex m_pendingTasksMutex;
121 DoubleBufferedDeque<TracedTask> m_pendingHighPriorityTasks;
122 double m_compositorPriorityPolicyEndTimeSeconds; 113 double m_compositorPriorityPolicyEndTimeSeconds;
123 114
124 // Declared volatile as it is atomically incremented. 115 // Declared volatile as it is atomically incremented.
125 volatile int m_highPriorityTaskCount; 116 volatile int m_highPriorityTaskCount;
126 117
127 bool m_highPriorityTaskRunnerPosted; 118 bool m_highPriorityTaskRunnerPosted;
128 119
129 // Don't access m_schedulerPolicy directly, use enterSchedulerPolicyLocked a nd SchedulerPolicy instead. 120 // Don't access m_schedulerPolicy directly, use enterSchedulerPolicyLocked a nd SchedulerPolicy instead.
130 volatile int m_schedulerPolicy; 121 volatile int m_schedulerPolicy;
131 }; 122 };
132 123
133 } // namespace blink 124 } // namespace blink
134 125
135 #endif // Scheduler_h 126 #endif // Scheduler_h
OLDNEW
« no previous file with comments | « no previous file | Source/platform/scheduler/Scheduler.cpp » ('j') | Source/platform/scheduler/Scheduler.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698