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

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: Respoding to more feedback 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
« 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 c492e580aa17268afe30b6c439a9c08acd08638f..23428efab2b11ebf60e87df3bc32abc03fa0591d 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 "public/platform/WebThread.h"
+#include "wtf/Deque.h"
#include "wtf/Functional.h"
#include "wtf/Noncopyable.h"
+#include "wtf/ThreadingPrimitives.h"
namespace blink {
class WebThread;
@@ -53,16 +57,54 @@ private:
Scheduler();
~Scheduler();
- void scheduleTask(const TraceLocation&, const Task&);
void scheduleIdleTask(const IdleTask&);
static void sharedTimerAdapter();
void tickSharedTimer();
static Scheduler* s_sharedScheduler;
- blink::WebThread* m_mainThread;
+ class TracedTask {
eseidel 2014/08/07 17:18:15 Why aren't all tasks's traced? I think we want on
Sami 2014/08/07 18:22:22 This is just an internal helper class, but I guess
alexclarke 2014/08/08 13:32:23 I'm not sure if you're suggesting we make TracedTa
Sami 2014/08/08 15:31:12 I think I agree that matching base's PostTask() in
+ public:
+ TracedTask(const Task& task, const TraceLocation& location)
+ : m_task(task)
+ , m_location(location) { }
+
+ void run();
+
+ private:
+ Task m_task;
+ TraceLocation m_location;
+ };
+
+ class LockingTracedTaskDeque {
+ public:
+ void append(const TracedTask& value);
+ bool isEmpty();
+
+ // Returns true if a task was executed, false otherwise.
+ bool runFirstTaskIfNotEmpty();
+
+ private:
+ WTF::Deque<TracedTask> m_queue;
+ Mutex m_mutex;
+ };
+
+ class MainThreadPendingTaskRunner;
+
+ // These members can be accessed from any thread.
+ blink::WebThread* m_mainThread;
+ LockingTracedTaskDeque m_pendingInputTasks;
eseidel 2014/08/07 17:18:15 Do these want separate locks or one big global loc
Sami 2014/08/07 18:22:22 I guess a global lock would be better if there is
alexclarke 2014/08/08 13:32:23 Double buffering the queues is an interesting idea
+ LockingTracedTaskDeque m_pendingCompositorTasks;
+ LockingTracedTaskDeque m_pendingLowPriorityTasks;
void (*m_sharedTimerFunction)();
+ volatile int m_mainThreadTaskRunnerCount;
eseidel 2014/08/07 17:18:15 volatile? I've never seen this used in Blink. I
Sami 2014/08/07 18:23:59 Yes, it's needed for atomic operations (and also u
alexclarke 2014/08/08 13:32:23 Pretty much. It's used in a few places in blink:
+
+ void maybePostMainThreadPendingTaskRunner();
+ void runHighPriorityTasks();
+ void runPendingTasks();
+
+ friend class MainThreadPendingTaskRunner;
};
} // namespace blink
« 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