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..08290d4aaa3f9caa2a2780b933e7bf10b434acc4 100644 |
| --- a/Source/platform/scheduler/Scheduler.h |
| +++ b/Source/platform/scheduler/Scheduler.h |
| @@ -6,8 +6,11 @@ |
| #define Scheduler_h |
| #include "platform/PlatformExport.h" |
| +#include "platform/TraceLocation.h" |
| +#include "wtf/DoubleBufferedDeque.h" |
| #include "wtf/Functional.h" |
| #include "wtf/Noncopyable.h" |
| +#include "wtf/ThreadingPrimitives.h" |
| namespace blink { |
| class WebThread; |
| @@ -36,11 +39,11 @@ public: |
| 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. |
| + void postIdleTask(const TraceLocation&, const IdleTask&); // For non-critical tasks which may be reordered relative to other task types. |
| // 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. |
| + // Can be called on any thread. |
| bool shouldYieldForHighPriorityWork(); |
| // The shared timer can be used to schedule a periodic callback which may |
| @@ -50,19 +53,51 @@ public: |
| void stopSharedTimer(); |
| private: |
| + class MainThreadPendingTaskRunner; |
| + class MainThreadPendingHighPriorityTaskRunner; |
| + friend class MainThreadPendingTaskRunner; |
| + friend class MainThreadPendingHighPriorityTaskRunner; |
| + |
| Scheduler(); |
| ~Scheduler(); |
| - void scheduleTask(const TraceLocation&, const Task&); |
| - void scheduleIdleTask(const IdleTask&); |
| + void scheduleIdleTask(const TraceLocation&, const IdleTask&); |
| static void sharedTimerAdapter(); |
| void tickSharedTimer(); |
| static Scheduler* s_sharedScheduler; |
| - blink::WebThread* m_mainThread; |
| + class TracedTask { |
| + public: |
| + TracedTask(const Task& task, const TraceLocation& location) |
| + : m_task(task) |
| + , m_location(location) { } |
| + |
| + void run(); |
| + |
| + private: |
| + Task m_task; |
| + TraceLocation m_location; |
| + }; |
| + |
| + void maybePostMainThreadPendingHighPriorityTaskRunner(); |
| + void runHighPriorityTasks(); |
| + |
| + void incrementMainThreadTaskRunnerCount(); |
|
eseidel
2014/08/11 17:02:36
Please add a comment to explain what these are for
alexclarke
2014/08/12 11:37:03
They've gone.
|
| + void decrementMainThreadTaskRunnerCount(); |
|
eseidel
2014/08/11 17:02:36
we should also add a comment that the only reason
alexclarke
2014/08/12 11:37:03
They've gone.
|
| + |
| + // These members can be accessed from any thread. |
| + WebThread* m_mainThread; |
| void (*m_sharedTimerFunction)(); |
| + volatile int m_mainThreadTaskRunnerCount; |
| + |
| + // This mutex protects calls to the pending task queues. |
| + Mutex m_pendingTasksMutex; |
| + DoubleBufferedDeque<TracedTask> m_pendingInputTasks; |
| + DoubleBufferedDeque<TracedTask> m_pendingCompositorTasks; |
| + |
| + volatile int m_highPriotityTaskCount; |
| }; |
| } // namespace blink |