1/*
2 * Copyright (C) 2017 Igalia, S.L.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#pragma once
21
22#if USE(GLIB)
23
24namespace WTF {
25
26#if PLATFORM(GTK)
27
28// This is a global enum to define priorities used by GLib run loop sources.
29// In GLib, priorities are represented by an integer where lower values mean
30// higher priority. The following macros are defined in GLib:
31// G_PRIORITY_LOW = 300
32// G_PRIORITY_DEFAULT_IDLE = 200
33// G_PRIORITY_HIGH_IDLE = 100
34// G_PRIORITY_DEFAULT = 0
35// G_PRIORITY_HIGH = -100
36// We don't use those macros here to avoid having to include glib header only
37// for this. But we should take into account that GLib uses G_PRIORITY_DEFAULT
38// for timeout sourcea and G_PRIORITY_DEFAULT_IDLE for idle sources.
39// Changes in these priorities can have a huge impact in performance, and in
40// the correctness too, so be careful when changing them.
41enum RunLoopSourcePriority {
42 // RunLoop::dispatch().
43 RunLoopDispatcher = 100,
44
45 // RunLoopTimer priority by default. It can be changed with RunLoopTimer::setPriority().
46 RunLoopTimer = 0,
47
48 // Garbage collector timers.
49 JavascriptTimer = 200,
50
51 // callOnMainThread.
52 MainThreadDispatcherTimer = 100,
53
54 // Memory pressure monitor.
55 MemoryPressureHandlerTimer = -100,
56
57 // WebCore timers.
58 MainThreadSharedTimer = 100,
59
60 // Used for timers that discard resources like backing store, buffers, etc.
61 ReleaseUnusedResourcesTimer = 200,
62
63 // Rendering timer in the threaded compositor.
64 CompositingThreadUpdateTimer = 110,
65
66 // Layer flush.
67 LayerFlushTimer = -100,
68
69 // DisplayRefreshMonitor timer, should have the same value as the LayerFlushTimer.
70 DisplayRefreshMonitorTimer = -100,
71
72 // Rendering timer in the main thread when accelerated compositing is not used.
73 NonAcceleratedDrawingTimer = 100,
74
75 // Async IO network callbacks.
76 AsyncIONetwork = 100,
77
78 // Disk cache read callbacks.
79 DiskCacheRead = 100,
80
81 // Disk cache write callbacks.
82 DiskCacheWrite = 200,
83};
84
85#elif PLATFORM(WPE)
86
87enum RunLoopSourcePriority {
88 RunLoopDispatcher = 0,
89 RunLoopTimer = 0,
90
91 MainThreadDispatcherTimer = 10,
92
93 MemoryPressureHandlerTimer = -10,
94
95 JavascriptTimer = 10,
96 MainThreadSharedTimer = 10,
97
98 LayerFlushTimer = 0,
99 DisplayRefreshMonitorTimer = 0,
100
101 CompositingThreadUpdateTimer = 0,
102
103 ReleaseUnusedResourcesTimer = 0,
104
105 AsyncIONetwork = 10,
106 DiskCacheRead = 10,
107 DiskCacheWrite = 20
108};
109
110#endif
111
112} // namespace WTF
113
114using WTF::RunLoopSourcePriority;
115
116#endif // USE(GLIB)
117