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

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

Issue 364873002: Introduce a basic Blink Scheduler (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Cleaned up includes + build fix. Created 6 years, 5 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef Scheduler_h
6 #define Scheduler_h
7
8 #include "platform/PlatformExport.h"
9 #include "wtf/Functional.h"
10 #include "wtf/Noncopyable.h"
11
12 namespace blink {
13 class WebThread;
14 }
15
16 namespace WebCore {
17
18 // The scheduler is an opinionated gateway for arranging work to be run the
19 // main thread. It decides which tasks get priority over others based on a
20 // scheduling policy and the overall system state.
21 class PLATFORM_EXPORT Scheduler {
22 WTF_MAKE_NONCOPYABLE(Scheduler);
23 public:
24 typedef Function<void()> Task;
25
26 static Scheduler* shared();
27 static void initializeOnMainThread();
28 static void shutdown();
29
30 // The following entrypoints are used to schedule different types of tasks
31 // to be run on the main thread. They can be called from any thread.
32 void postInputTask(const Task&);
33 void postCompositorTask(const Task&);
34 void postTask(const Task&); // For generic (low priority) tasks.
35
36 // Returns true if there is high priority work pending on the main thread
37 // and the caller should yield to let the scheduler service that work.
38 // Can be called on the main thread.
39 bool shouldYieldForHighPriorityWork();
40
41 // The shared timer can be used to schedule a periodic callback which may
42 // get preempted by higher priority work.
43 void setSharedTimerFiredFunction(void (*function)());
44 void setSharedTimerFireInterval(double);
45 void stopSharedTimer();
46
47 private:
48 Scheduler();
49 ~Scheduler();
50
51 void scheduleTask(const Task&);
52
53 static void sharedTimerAdapter();
54 void tickSharedTimer();
55
56 static Scheduler* s_sharedScheduler;
57 blink::WebThread* m_mainThread;
58
59 void (*m_sharedTimerFunction)();
60 };
61
62 } // namespace WebCore
63
64 #endif // Scheduler_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698