| OLD | NEW |
| 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" | 9 #include "platform/TraceLocation.h" |
| 10 #include "wtf/DoubleBufferedDeque.h" | 10 #include "wtf/DoubleBufferedDeque.h" |
| 11 #include "wtf/Functional.h" | 11 #include "wtf/Functional.h" |
| 12 #include "wtf/Noncopyable.h" | 12 #include "wtf/Noncopyable.h" |
| 13 #include "wtf/ThreadingPrimitives.h" | 13 #include "wtf/ThreadingPrimitives.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 class WebThread; | |
| 17 } | |
| 18 | |
| 19 namespace blink { | |
| 20 | 16 |
| 21 // The scheduler is an opinionated gateway for arranging work to be run on the | 17 // The scheduler is an opinionated gateway for arranging work to be run on the |
| 22 // main thread. It decides which tasks get priority over others based on a | 18 // main thread. It decides which tasks get priority over others based on a |
| 23 // scheduling policy and the overall system state. | 19 // scheduling policy and the overall system state. |
| 20 class WebThread; |
| 21 |
| 24 class PLATFORM_EXPORT Scheduler { | 22 class PLATFORM_EXPORT Scheduler { |
| 25 WTF_MAKE_NONCOPYABLE(Scheduler); | 23 WTF_MAKE_NONCOPYABLE(Scheduler); |
| 26 public: | 24 public: |
| 27 typedef Function<void()> Task; | 25 typedef Function<void()> Task; |
| 28 // An IdleTask is passed an allotted time in CLOCK_MONOTONIC milliseconds an
d is expected to complete within this timeframe. | 26 // An IdleTask is passed an allotted time in CLOCK_MONOTONIC milliseconds an
d is expected to complete within this timeframe. |
| 29 typedef Function<void(double allottedTimeMs)> IdleTask; | 27 typedef Function<void(double allottedTimeMs)> IdleTask; |
| 30 | 28 |
| 31 static Scheduler* shared(); | 29 static Scheduler* shared(); |
| 32 static void initializeOnMainThread(); | 30 static void initializeOnMainThread(); |
| 33 static void shutdown(); | 31 static void shutdown(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // This mutex protects calls to the pending task queue. | 89 // This mutex protects calls to the pending task queue. |
| 92 Mutex m_pendingTasksMutex; | 90 Mutex m_pendingTasksMutex; |
| 93 DoubleBufferedDeque<TracedTask> m_pendingHighPriorityTasks; | 91 DoubleBufferedDeque<TracedTask> m_pendingHighPriorityTasks; |
| 94 | 92 |
| 95 volatile int m_highPriorityTaskCount; | 93 volatile int m_highPriorityTaskCount; |
| 96 }; | 94 }; |
| 97 | 95 |
| 98 } // namespace blink | 96 } // namespace blink |
| 99 | 97 |
| 100 #endif // Scheduler_h | 98 #endif // Scheduler_h |
| OLD | NEW |