Chromium Code Reviews| Index: Source/platform/scheduler/Scheduler.h |
| diff --git a/Source/platform/scheduler/Scheduler.h b/Source/platform/scheduler/Scheduler.h |
| index c492e580aa17268afe30b6c439a9c08acd08638f..1fb0445baee87426a6545b0f254f4964af18c58a 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; |
| @@ -49,20 +53,66 @@ public: |
| void setSharedTimerFireInterval(double); |
| void stopSharedTimer(); |
| + void runPendingTasks(); |
|
Sami
2014/08/07 14:24:45
This one doesn't need to be public, does it?
|
| + |
| 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 { |
| + public: |
| + TracedTask(Task task, TraceLocation location) |
|
Sami
2014/08/07 14:24:45
const Task& and const TraceLocation&
alexclarke
2014/08/07 15:15:29
Done.
|
| + : m_task(task) |
| + , m_location(location) { } |
| + |
| + void run(); |
| + |
| + private: |
| + Task m_task; |
| + TraceLocation m_location; |
| + }; |
| + |
| + class LockingTracedTaskDeque { |
| + public: |
| + void append(const TracedTask& value) |
| + { |
| + Locker<Mutex> lock(m_mutex); |
| + m_queue.append(value); |
| + } |
| + |
| + bool isEmpty() |
|
Sami
2014/08/07 14:24:45
Could we somehow combine isEmpty() and takeFirst()
alexclarke
2014/08/07 15:15:29
Done.
|
| + { |
| + Locker<Mutex> lock(m_mutex); |
| + return m_queue.isEmpty(); |
| + } |
| + |
| + TracedTask takeFirst() |
| + { |
| + Locker<Mutex> lock(m_mutex); |
| + return m_queue.takeFirst(); |
| + } |
| + |
| + private: |
| + WTF::Deque<TracedTask> m_queue; |
| + Mutex m_mutex; |
| + }; |
| + |
| + // These members can be accessed from any thread. |
| + blink::WebThread* m_mainThread; |
| + LockingTracedTaskDeque m_pendingInputTasks; |
| + LockingTracedTaskDeque m_pendingCompositorTasks; |
| + LockingTracedTaskDeque m_pendingLowPriorityTasks; |
| void (*m_sharedTimerFunction)(); |
|
Sami
2014/08/07 14:24:45
This member should only be used on the main thread
|
| + |
| + void maybePostTaskLoopOnMainThread(); |
|
Sami
2014/08/07 14:24:45
Could you move these two before the data member de
|
| + void runHighPriorityTasks(); |
| }; |
| } // namespace blink |