Chromium Code Reviews| 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 "wtf/Functional.h" | 9 #include "wtf/Functional.h" |
| 10 #include "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
|
yhirano
2014/11/07 06:05:28
+#include "wtf/PassOwnPtr.h"
hiroshige
2014/11/07 07:16:59
Done.
| |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 class TraceLocation; | 13 class TraceLocation; |
| 14 class WebScheduler; | 14 class WebScheduler; |
| 15 | 15 |
| 16 // The scheduler is an opinionated gateway for arranging work to be run on the | 16 // The scheduler is an opinionated gateway for arranging work to be run on the |
| 17 // main thread. It decides which tasks get priority over others based on a | 17 // main thread. It decides which tasks get priority over others based on a |
| 18 // scheduling policy and the overall system state. | 18 // scheduling policy and the overall system state. |
| 19 class PLATFORM_EXPORT Scheduler { | 19 class PLATFORM_EXPORT Scheduler { |
| 20 WTF_MAKE_NONCOPYABLE(Scheduler); | 20 WTF_MAKE_NONCOPYABLE(Scheduler); |
| 21 public: | 21 public: |
| 22 // An IdleTask is passed a deadline in CLOCK_MONOTONIC seconds and is expect ed to complete before this deadline. | 22 // An IdleTask is passed a deadline in CLOCK_MONOTONIC seconds and is expect ed to complete before this deadline. |
| 23 typedef Function<void(double deadlineSeconds)> IdleTask; | 23 typedef Function<void(double deadlineSeconds)> IdleTask; |
| 24 | 24 |
| 25 static Scheduler* shared(); | 25 static Scheduler* shared(); |
| 26 static void shutdown(); | 26 static void shutdown(); |
| 27 | 27 |
| 28 // For non-critical tasks which may be reordered relative to other task type s and may be starved | 28 // For non-critical tasks which may be reordered relative to other task type s and may be starved |
| 29 // for an arbitrarily long time if no idle time is available. | 29 // for an arbitrarily long time if no idle time is available. |
| 30 void postIdleTask(const TraceLocation&, const IdleTask&); | 30 void postIdleTask(const TraceLocation&, PassOwnPtr<IdleTask>); |
| 31 | 31 |
| 32 // Returns true if there is high priority work pending on the main thread | 32 // Returns true if there is high priority work pending on the main thread |
| 33 // and the caller should yield to let the scheduler service that work. | 33 // and the caller should yield to let the scheduler service that work. |
| 34 // Must be called on the main thread. | 34 // Must be called on the main thread. |
| 35 bool shouldYieldForHighPriorityWork() const; | 35 bool shouldYieldForHighPriorityWork() const; |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 Scheduler(WebScheduler*); | 38 Scheduler(WebScheduler*); |
| 39 virtual ~Scheduler(); | 39 virtual ~Scheduler(); |
| 40 | 40 |
| 41 static Scheduler* s_sharedScheduler; | 41 static Scheduler* s_sharedScheduler; |
| 42 WebScheduler* m_webScheduler; | 42 WebScheduler* m_webScheduler; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 } // namespace blink | 45 } // namespace blink |
| 46 | 46 |
| 47 #endif // Scheduler_h | 47 #endif // Scheduler_h |
| OLD | NEW |