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

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

Issue 595023002: Implement idle task scheduling. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Change function names. 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') | Source/platform/scheduler/Scheduler.cpp » ('J')
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 7f7835abcf76d6ac90c6780e6fdad520e3808d80..d4166c4e4b749b95c7f293cd3f203e7e86a41353 100644
--- a/Source/platform/scheduler/Scheduler.h
+++ b/Source/platform/scheduler/Scheduler.h
@@ -23,15 +23,15 @@ class PLATFORM_EXPORT Scheduler {
WTF_MAKE_NONCOPYABLE(Scheduler);
public:
typedef Function<void()> Task;
- // An IdleTask is passed an allotted time in CLOCK_MONOTONIC milliseconds and is expected to complete within this timeframe.
- typedef Function<void(double allottedTimeMs)> IdleTask;
+ // An IdleTask is passed a deadline in CLOCK_MONOTONIC seconds and is expected to complete before this deadline.
+ typedef Function<void(double deadlineSeconds)> IdleTask;
static Scheduler* shared();
static void initializeOnMainThread();
static void shutdown();
// Called to notify about the start of a new frame.
- void willBeginFrame(const WebBeginFrameArgs&);
+ void willBeginFrame(double frameDeadlineSeconds);
// Called to notify that a previously begun frame was committed.
void didCommitFrameToCompositor();
@@ -62,8 +62,10 @@ public:
protected:
class MainThreadPendingTaskRunner;
class MainThreadPendingHighPriorityTaskRunner;
+ class MainThreadPendingIdleTaskRunner;
friend class MainThreadPendingTaskRunner;
friend class MainThreadPendingHighPriorityTaskRunner;
+ friend class TracedIdleTask;
enum SchedulerPolicy {
Normal,
@@ -73,8 +75,8 @@ protected:
Scheduler();
virtual ~Scheduler();
- void scheduleIdleTask(const TraceLocation&, const IdleTask&);
void postHighPriorityTaskInternal(const TraceLocation&, const Task&, const char* traceName);
+ void postIdleTaskInternal(const TraceLocation&, const IdleTask&, const char* traceName);
static void sharedTimerAdapter();
@@ -89,7 +91,16 @@ protected:
void swapQueuesRunPendingTasksAndAllowHighPriorityTaskRunnerPosting();
// Returns true if any work was done.
- bool executeHighPriorityTasks(Deque<TracedTask>&);
+ bool executeHighPriorityTasks(Deque<TracedStandardTask>&);
+
+ // Reposts all the tasks in idleTasks onto the idle task queue.
+ void repostIdleTaskAtFront(const TracedIdleTask&);
+
+ // Returns the time in CLOCK_MONOTONIC seconds until the current frame deadline expires.
+ double currentFrameDeadlineSeconds() const;
+
+ // Returns true if the scheduler can run idle tasks at this time.
+ bool canRunIdleTask() const;
// Return the current SchedulerPolicy.
SchedulerPolicy schedulerPolicy() const;
@@ -99,6 +110,9 @@ protected:
// Must be called while m_pendingTasksMutex is locked.
void maybePostMainThreadPendingHighPriorityTaskRunner();
+ // Returns true if an idle task was posted to the main thread for execution.
+ bool maybePostMainThreadPendingIdleTask();
+
void tickSharedTimer();
void (*m_sharedTimerFunction)();
@@ -118,9 +132,13 @@ protected:
// This mutex protects calls to the pending task queue, m_highPriorityTaskRunnerPosted and
// m_compositorPriorityPolicyEndTimeSeconds.
Mutex m_pendingTasksMutex;
- DoubleBufferedDeque<TracedTask> m_pendingHighPriorityTasks;
+ DoubleBufferedDeque<TracedStandardTask> m_pendingHighPriorityTasks;
+ Deque<TracedIdleTask> m_pendingIdleTasks;
double m_compositorPriorityPolicyEndTimeSeconds;
+ bool m_currentFrameCommitted;
+ double m_currentFrameDeadlineSeconds;
+
// Declared volatile as it is atomically incremented.
volatile int m_highPriorityTaskCount;
« 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