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

Unified Diff: Source/platform/scheduler/Scheduler.h

Issue 559973003: Adds the concept of Policies to the Blink Scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Change the test time funcstions to be non-static Created 6 years, 3 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 | Source/platform/scheduler/Scheduler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/scheduler/Scheduler.h
diff --git a/Source/platform/scheduler/Scheduler.h b/Source/platform/scheduler/Scheduler.h
index 9524ec37a34d76596985ea4f2c438e84bb52dbef..215662bb6d33a2d618624b1cfccf19954298d077 100644
--- a/Source/platform/scheduler/Scheduler.h
+++ b/Source/platform/scheduler/Scheduler.h
@@ -54,12 +54,17 @@ public:
void setSharedTimerFireInterval(double);
void stopSharedTimer();
-private:
+protected:
class MainThreadPendingTaskRunner;
class MainThreadPendingHighPriorityTaskRunner;
friend class MainThreadPendingTaskRunner;
friend class MainThreadPendingHighPriorityTaskRunner;
+ enum SchedulerPolicy {
+ Normal,
+ CompositorPriority,
+ };
+
class TracedTask {
public:
TracedTask(const Task& task, const TraceLocation& location)
@@ -74,37 +79,62 @@ private:
};
Scheduler();
- ~Scheduler();
-
- void scheduleIdleTask(const TraceLocation&, const IdleTask&);
+ virtual ~Scheduler();
static void sharedTimerAdapter();
- void tickSharedTimer();
- bool hasPendingHighPriorityWork() const;
+
+ // Start of main thread only members -----------------------------------
+
+ // Only does work in CompositorPriority mode. Returns true if any work was done.
+ bool runPendingHighPriorityTasksIfInCompositorPriority();
+
+ // Returns true if any work was done.
bool swapQueuesAndRunPendingTasks();
+
void swapQueuesRunPendingTasksAndAllowHighPriorityTaskRunnerPosting();
// Returns true if any work was done.
bool executeHighPriorityTasks(Deque<TracedTask>&);
+ // Return the current SchedulerPolicy.
+ SchedulerPolicy schedulerPolicy() const;
+
+ void maybeEnterNormalSchedulerPolicy();
+
// Must be called while m_pendingTasksMutex is locked.
void maybePostMainThreadPendingHighPriorityTaskRunner();
- static Scheduler* s_sharedScheduler;
+ void tickSharedTimer();
- // Should only be accessed from the main thread.
void (*m_sharedTimerFunction)();
- // These members can be accessed from any thread.
+ // End of main thread only members -------------------------------------
+
+
+ void scheduleIdleTask(const TraceLocation&, const IdleTask&);
+
+ bool hasPendingHighPriorityWork() const;
+
+ void enterSchedulerPolicyLocked(SchedulerPolicy);
+
+ void enterSchedulerPolicy(SchedulerPolicy);
+
+ static Scheduler* s_sharedScheduler;
+
WebThread* m_mainThread;
- // This mutex protects calls to the pending task queue and m_highPriorityTaskRunnerPosted.
+ // This mutex protects calls to the pending task queue, m_highPriorityTaskRunnerPosted and
+ // m_compositorPriorityPolicyEndTimeSeconds.
Mutex m_pendingTasksMutex;
DoubleBufferedDeque<TracedTask> m_pendingHighPriorityTasks;
+ double m_compositorPriorityPolicyEndTimeSeconds;
volatile int m_highPriorityTaskCount;
bool m_highPriorityTaskRunnerPosted;
+
+ // Don't access m_schedulerPolicy directly, use enterSchedulerPolicyLocked and SchedulerPolicy instead.
+ volatile int m_schedulerPolicy;
};
} // namespace blink
« no previous file with comments | « no previous file | Source/platform/scheduler/Scheduler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698