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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef Scheduler_h 5 #ifndef Scheduler_h
6 #define Scheduler_h 6 #define Scheduler_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/TraceLocation.h"
10 #include "public/platform/WebThread.h"
11 #include "wtf/Deque.h"
9 #include "wtf/Functional.h" 12 #include "wtf/Functional.h"
10 #include "wtf/Noncopyable.h" 13 #include "wtf/Noncopyable.h"
14 #include "wtf/ThreadingPrimitives.h"
11 15
12 namespace blink { 16 namespace blink {
13 class WebThread; 17 class WebThread;
14 } 18 }
15 19
16 namespace blink { 20 namespace blink {
17 21
18 class TraceLocation; 22 class TraceLocation;
19 23
20 // The scheduler is an opinionated gateway for arranging work to be run on the 24 // The scheduler is an opinionated gateway for arranging work to be run on the
(...skipping 25 matching lines...) Expand all
46 // The shared timer can be used to schedule a periodic callback which may 50 // The shared timer can be used to schedule a periodic callback which may
47 // get preempted by higher priority work. 51 // get preempted by higher priority work.
48 void setSharedTimerFiredFunction(void (*function)()); 52 void setSharedTimerFiredFunction(void (*function)());
49 void setSharedTimerFireInterval(double); 53 void setSharedTimerFireInterval(double);
50 void stopSharedTimer(); 54 void stopSharedTimer();
51 55
52 private: 56 private:
53 Scheduler(); 57 Scheduler();
54 ~Scheduler(); 58 ~Scheduler();
55 59
56 void scheduleTask(const TraceLocation&, const Task&);
57 void scheduleIdleTask(const IdleTask&); 60 void scheduleIdleTask(const IdleTask&);
58 61
59 static void sharedTimerAdapter(); 62 static void sharedTimerAdapter();
60 void tickSharedTimer(); 63 void tickSharedTimer();
61 64
62 static Scheduler* s_sharedScheduler; 65 static Scheduler* s_sharedScheduler;
66
67 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
68 public:
69 TracedTask(const Task& task, const TraceLocation& location)
70 : m_task(task)
71 , m_location(location) { }
72
73 void run();
74
75 private:
76 Task m_task;
77 TraceLocation m_location;
78 };
79
80 class LockingTracedTaskDeque {
81 public:
82 void append(const TracedTask& value);
83 bool isEmpty();
84
85 // Returns true if a task was executed, false otherwise.
86 bool runFirstTaskIfNotEmpty();
87
88 private:
89 WTF::Deque<TracedTask> m_queue;
90 Mutex m_mutex;
91 };
92
93 class MainThreadPendingTaskRunner;
94
95 // These members can be accessed from any thread.
63 blink::WebThread* m_mainThread; 96 blink::WebThread* m_mainThread;
97 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
98 LockingTracedTaskDeque m_pendingCompositorTasks;
99 LockingTracedTaskDeque m_pendingLowPriorityTasks;
100 void (*m_sharedTimerFunction)();
101 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:
64 102
65 void (*m_sharedTimerFunction)(); 103 void maybePostMainThreadPendingTaskRunner();
104 void runHighPriorityTasks();
105 void runPendingTasks();
106
107 friend class MainThreadPendingTaskRunner;
66 }; 108 };
67 109
68 } // namespace blink 110 } // namespace blink
69 111
70 #endif // Scheduler_h 112 #endif // Scheduler_h
OLDNEW
« 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