Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: Source/platform/scheduler/Scheduler.h

Issue 705003002: Change the return type of WTF::bind() to |OwnPtr<Function>| (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698