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

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

Issue 439923006: Prioritizing input and compositor tasks in the blink scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
Index: Source/platform/scheduler/Scheduler.h
diff --git a/Source/platform/scheduler/Scheduler.h b/Source/platform/scheduler/Scheduler.h
index c492e580aa17268afe30b6c439a9c08acd08638f..69ad86d00abdbe0a24c7d90ef6d0837e742e0370 100644
--- a/Source/platform/scheduler/Scheduler.h
+++ b/Source/platform/scheduler/Scheduler.h
@@ -6,8 +6,12 @@
#define Scheduler_h
#include "platform/PlatformExport.h"
+#include "platform/TraceLocation.h"
+#include "platform/scheduler/AtomicRingbuffer.h"
+#include "wtf/Deque.h"
#include "wtf/Functional.h"
#include "wtf/Noncopyable.h"
+#include "wtf/ThreadingPrimitives.h"
namespace blink {
class WebThread;
@@ -35,9 +39,11 @@ public:
// 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 postTask(const TraceLocation&, const Task&); // For generic (low priority) tasks.
void postIdleTask(const IdleTask&); // For non-critical tasks which may be reordered relative to other task types.
+ // For generic (low priority) tasks, can only be called from the main thread.
+ void postTask(const TraceLocation&, const Task&);
+
// 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.
@@ -49,11 +55,13 @@ public:
void setSharedTimerFireInterval(double);
void stopSharedTimer();
+ void runPendingTasks();
+ void allowMainThreadTaskPosting();
+
private:
Scheduler();
~Scheduler();
- void scheduleTask(const TraceLocation&, const Task&);
void scheduleIdleTask(const IdleTask&);
static void sharedTimerAdapter();
@@ -62,6 +70,31 @@ private:
static Scheduler* s_sharedScheduler;
blink::WebThread* m_mainThread;
+ class TracedTask {
+ public:
+ TracedTask(Task task, TraceLocation location) : m_task(task), m_location(location) { }
Sami 2014/08/06 10:19:52 nit: Initializer style.
alexclarke 2014/08/07 12:08:06 Done.
+
+ void run();
+
+ private:
+ Task m_task;
+ TraceLocation m_location;
+ };
+
+ // The input and compositor task queues can be posted to from any thread.
+ AtomicRingBuffer<TracedTask, 128> m_pendingInputTasks;
Sami 2014/08/06 10:19:52 One pattern we could steal from cc/ is to put memb
alexclarke 2014/08/07 12:08:06 I quite like that pattern, however I don't think w
+ AtomicRingBuffer<TracedTask, 128> m_pendingCompositorTasks;
+
+ // Blink tasks can only be posted on the main thread.
+ WTF::Deque<TracedTask> m_pendingBlinkTasks;
Sami 2014/08/06 10:19:52 m_pendingLowPriorityTasks or something?
alexclarke 2014/08/07 12:08:06 Done.
+
+ volatile int m_mainThreadTaskPosted;
+ volatile int m_blinkShouldNotYield;
+
+ void setBlinkShouldYield();
Sami 2014/08/06 10:19:52 How about setHighPriorityWorkPending to match shou
alexclarke 2014/08/07 12:08:06 I've decided not to use atomics, nailing down all
+ void clearBlinkShouldYield();
+ void maybePostTaskLoopOnMainThread();
+
void (*m_sharedTimerFunction)();
};

Powered by Google App Engine
This is Rietveld 408576698