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..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 |