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

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

Issue 656463004: Use the scheduling mechanism provided by the platform (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Mike's comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | 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 e63eb192000c512045e941537901b791b6d1f611..62b08a69f0f1098aa97ad97e13f2f57f9e48767a 100644
--- a/Source/platform/scheduler/Scheduler.h
+++ b/Source/platform/scheduler/Scheduler.h
@@ -6,15 +6,12 @@
#define Scheduler_h
#include "platform/PlatformExport.h"
-#include "platform/scheduler/TracedTask.h"
-#include "wtf/DoubleBufferedDeque.h"
#include "wtf/Functional.h"
#include "wtf/Noncopyable.h"
-#include "wtf/ThreadingPrimitives.h"
namespace blink {
-class WebThread;
-struct WebBeginFrameArgs;
+class TraceLocation;
+class WebScheduler;
// The scheduler is an opinionated gateway for arranging work to be run on the
// main thread. It decides which tasks get priority over others based on a
@@ -22,123 +19,27 @@ struct WebBeginFrameArgs;
class PLATFORM_EXPORT Scheduler {
WTF_MAKE_NONCOPYABLE(Scheduler);
public:
- typedef Function<void()> Task;
// 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(double estimatedNextBeginFrameSeconds);
-
- // Called to notify that a previously begun frame was committed.
- void didCommitFrameToCompositor();
-
- // The following entrypoints are used to schedule different types of tasks
- // to be run on the main thread. They can be called from any thread.
- void postInputTask(const TraceLocation&, const Task&);
- void postCompositorTask(const TraceLocation&, const Task&);
- void postIpcTask(const TraceLocation&, const Task&);
- void postTask(const TraceLocation&, const Task&); // For generic (low priority) tasks.
// For non-critical tasks which may be reordered relative to other task types and may be starved
// for an arbitrarily long time if no idle time is available.
void postIdleTask(const TraceLocation&, const IdleTask&);
- // Tells the scheduler that the system received an input event. This causes the scheduler to go into
- // Compositor Priority mode for a short duration.
- void didReceiveInputEvent();
-
// Returns true if there is high priority work pending on the main thread
// and the caller should yield to let the scheduler service that work.
- // Can be called on any thread.
+ // Must be called on the main thread.
bool shouldYieldForHighPriorityWork() const;
- // The shared timer can be used to schedule a periodic callback which may
- // get preempted by higher priority work.
- void setSharedTimerFiredFunction(void (*function)());
- void setSharedTimerFireInterval(double);
- void stopSharedTimer();
-
- // Returns the deadline, in CLOCK_MONOTONIC seconds, which an idle task should
- // finish by for the current frame.
- double currentFrameDeadlineForIdleTasks() const;
-
protected:
- class MainThreadPendingTaskRunner;
- class MainThreadPendingHighPriorityTaskRunner;
- class MainThreadPendingIdleTaskRunner;
- friend class MainThreadPendingTaskRunner;
- friend class MainThreadPendingHighPriorityTaskRunner;
-
- enum SchedulerPolicy {
- Normal,
- CompositorPriority,
- };
-
- Scheduler();
+ Scheduler(WebScheduler*);
virtual ~Scheduler();
- void postHighPriorityTaskInternal(const TraceLocation&, const Task&, const char* traceName);
- void postIdleTaskInternal(const TraceLocation&, const IdleTask&, const char* traceName);
- void didRunHighPriorityTask();
-
- static void sharedTimerAdapter();
-
- // Start of main thread only members -----------------------------------
-
- // Only does work in CompositorPriority mode. Returns true if any work was done.
- bool runPendingHighPriorityTasksIfInCompositorPriority();
-
- // Returns true if an idle task was posted to the main thread for execution.
- bool maybePostMainThreadPendingIdleTask();
-
- // Only does work if canRunIdleTask. Returns true if any work was done.
- bool maybeRunPendingIdleTask();
-
- // Returns true if the scheduler can run idle tasks at this time.
- bool canRunIdleTask() const;
-
- // Flush the incoming idle tasks to the end of the pending idle task queue.
- void flushIncomingIdleTasks();
-
- // Return the current SchedulerPolicy.
- SchedulerPolicy schedulerPolicy() const;
-
- void updatePolicy();
-
- void tickSharedTimer();
-
- void (*m_sharedTimerFunction)();
-
- // End of main thread only members -------------------------------------
-
- void enterSchedulerPolicyLocked(SchedulerPolicy);
- void enterSchedulerPolicy(SchedulerPolicy);
-
static Scheduler* s_sharedScheduler;
-
- WebThread* m_mainThread;
-
- // This mutex protects calls to the incoming idle task queue.
- Mutex m_incomingIdleTasksMutex;
- Deque<OwnPtr<internal::TracedIdleTask>> m_incomingIdleTasks;
-
- bool m_currentFrameCommitted;
- double m_estimatedNextBeginFrameSeconds;
- Deque<OwnPtr<internal::TracedIdleTask>> m_pendingIdleTasks;
-
- // Declared volatile as it is atomically incremented.
- volatile int m_highPriorityTaskCount;
-
- bool m_highPriorityTaskRunnerPosted;
-
- Mutex m_policyStateMutex;
- double m_compositorPriorityPolicyEndTimeSeconds;
-
- // Don't access m_schedulerPolicy directly, use enterSchedulerPolicyLocked and schedulerPolicy instead.
- volatile int m_schedulerPolicy;
+ WebScheduler* m_webScheduler;
};
} // namespace blink
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/scheduler/Scheduler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698