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

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

Issue 364873002: Introduce a basic Blink Scheduler (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review feedback. Created 6 years, 5 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/exported/WebSchedulerProxy.cpp ('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
new file mode 100644
index 0000000000000000000000000000000000000000..b07e27a54c85795d8f149a060a8efa1eb46b35ed
--- /dev/null
+++ b/Source/platform/scheduler/Scheduler.h
@@ -0,0 +1,63 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef Scheduler_h
+#define Scheduler_h
+
+#include "platform/PlatformExport.h"
+#include "public/platform/WebThread.h"
+#include "wtf/Functional.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/ThreadingPrimitives.h"
+#include <deque>
eseidel 2014/07/15 19:32:37 Why is this needed?
Sami 2014/07/16 10:28:07 Oops, left over from an earlier version. I've clea
+
+namespace WebCore {
+
+// The scheduler is an opinionated gateway for arranging work to be run the
+// main thread. It decides which tasks get priority over others based on a
+// scheduling policy and the overall system state.
+class PLATFORM_EXPORT Scheduler {
+ WTF_MAKE_NONCOPYABLE(Scheduler);
+public:
+ typedef Function<void()> Task;
+
+ static Scheduler* shared();
+ static void initializeOnMainThread();
+ static void shutdown();
+
+ // 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 Task&);
+ void postCompositorTask(const Task&);
+ void postTask(const Task&); // For generic (low priority) tasks.
+
+ // 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 the main thread.
+ bool shouldYieldForHighPriorityWork();
+
+ // 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();
+
+private:
+ Scheduler();
+ ~Scheduler();
+
+ void scheduleTask(const Task&);
+
+ static void sharedTimerAdapter();
+ void tickSharedTimer();
+
+ static Scheduler* s_sharedScheduler;
+ blink::WebThread* m_mainThread;
+
+ void (*m_sharedTimerFunction)();
+};
+
+} // namespace WebCore
+
+#endif // Scheduler_h
« no previous file with comments | « Source/platform/exported/WebSchedulerProxy.cpp ('k') | Source/platform/scheduler/Scheduler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698