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

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: Review feedback. 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
« no previous file with comments | « Source/platform/exported/WebSchedulerProxy.cpp ('k') | Source/platform/scheduler/Scheduler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "public/platform/WebThread.h"
10 #include "wtf/Functional.h"
11 #include "wtf/Noncopyable.h"
12 #include "wtf/ThreadingPrimitives.h"
13 #include <deque>
eseidel 2014/07/15 19:32:37 Why is this needed?
Sami 2014/07/16 10:28:07 Oops, left over from an earlier version. I've clea
14
15 namespace WebCore {
16
17 // The scheduler is an opinionated gateway for arranging work to be run the
18 // main thread. It decides which tasks get priority over others based on a
19 // scheduling policy and the overall system state.
20 class PLATFORM_EXPORT Scheduler {
21 WTF_MAKE_NONCOPYABLE(Scheduler);
22 public:
23 typedef Function<void()> Task;
24
25 static Scheduler* shared();
26 static void initializeOnMainThread();
27 static void shutdown();
28
29 // The following entrypoints are used to schedule different types of tasks
30 // to be run on the main thread. They can be called from any thread.
31 void postInputTask(const Task&);
32 void postCompositorTask(const Task&);
33 void postTask(const Task&); // For generic (low priority) tasks.
34
35 // Returns true if there is high priority work pending on the main thread
36 // and the caller should yield to let the scheduler service that work.
37 // Can be called on the main thread.
38 bool shouldYieldForHighPriorityWork();
39
40 // The shared timer can be used to schedule a periodic callback which may
41 // get preempted by higher priority work.
42 void setSharedTimerFiredFunction(void (*function)());
43 void setSharedTimerFireInterval(double);
44 void stopSharedTimer();
45
46 private:
47 Scheduler();
48 ~Scheduler();
49
50 void scheduleTask(const Task&);
51
52 static void sharedTimerAdapter();
53 void tickSharedTimer();
54
55 static Scheduler* s_sharedScheduler;
56 blink::WebThread* m_mainThread;
57
58 void (*m_sharedTimerFunction)();
59 };
60
61 } // namespace WebCore
62
63 #endif // Scheduler_h
OLDNEW
« no previous file with comments | « Source/platform/exported/WebSchedulerProxy.cpp ('k') | Source/platform/scheduler/Scheduler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698