Changeset 191852 in webkit
- Timestamp:
- Nov 1, 2015 12:54:38 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r191849 r191852 1 2015-11-01 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Use RunLoop::Timer in main thread shared timer GTK+ implementation 4 https://bugs.webkit.org/show_bug.cgi?id=150754 5 6 Reviewed by Darin Adler. 7 8 Add API to set the priority of a RunLoop::Timer for GLib. 9 10 * wtf/RunLoop.h: 11 * wtf/glib/RunLoopGLib.cpp: 12 (WTF::RunLoop::TimerBase::setPriority): 13 1 14 2015-10-31 Andreas Kling <akling@apple.com> 2 15 -
trunk/Source/WTF/wtf/RunLoop.h
r191786 r191852 83 83 84 84 virtual void fired() = 0; 85 86 #if USE(GLIB) && !PLATFORM(EFL) 87 void setPriority(int); 88 #endif 85 89 86 90 private: -
trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp
r191786 r191852 142 142 } 143 143 144 void RunLoop::TimerBase::setPriority(int priority) 145 { 146 g_source_set_priority(m_source.get(), priority); 147 } 148 144 149 void RunLoop::TimerBase::updateReadyTime() 145 150 { -
trunk/Source/WebCore/ChangeLog
r191851 r191852 1 2015-11-01 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Use RunLoop::Timer in main thread shared timer GTK+ implementation 4 https://bugs.webkit.org/show_bug.cgi?id=150754 5 6 Reviewed by Darin Adler. 7 8 It's more efficient because it uses a persistent source and it 9 simplifies the code even more. 10 11 * platform/MainThreadSharedTimer.cpp: 12 (WebCore::MainThreadSharedTimer::fired): Make it non-const to be 13 able to use it as function callback of a RunLoop::Timer. 14 * platform/MainThreadSharedTimer.h: 15 * platform/gtk/MainThreadSharedTimerGtk.cpp: 16 (WebCore::MainThreadSharedTimer::MainThreadSharedTimer): 17 Initialize the RunLoop::Timer and set the prioriry. 18 (WebCore::MainThreadSharedTimer::setFireInterval): 19 (WebCore::MainThreadSharedTimer::stop): 20 1 21 2015-10-31 Andreas Kling <akling@apple.com> 2 22 -
trunk/Source/WebCore/platform/MainThreadSharedTimer.cpp
r191789 r191852 35 35 } 36 36 37 #if !PLATFORM(GTK) 37 38 MainThreadSharedTimer::MainThreadSharedTimer() 38 39 { 39 40 } 41 #endif 40 42 41 43 void MainThreadSharedTimer::setFiredFunction(std::function<void()>&& firedFunction) … … 45 47 } 46 48 47 void MainThreadSharedTimer::fired() const49 void MainThreadSharedTimer::fired() 48 50 { 49 51 ASSERT(m_firedFunction); -
trunk/Source/WebCore/platform/MainThreadSharedTimer.h
r191789 r191852 31 31 #include <wtf/NeverDestroyed.h> 32 32 33 #if PLATFORM(GTK) 34 #include <wtf/RunLoop.h> 35 #endif 36 33 37 namespace WebCore { 34 38 … … 45 49 // FIXME: This should be private, but CF and Windows implementations 46 50 // need to call this from non-member functions at the moment. 47 void fired() const;51 void fired(); 48 52 49 53 private: … … 51 55 52 56 std::function<void()> m_firedFunction; 57 #if PLATFORM(GTK) 58 RunLoop::Timer<MainThreadSharedTimer> m_timer; 59 #endif 53 60 }; 54 61 -
trunk/Source/WebCore/platform/gtk/MainThreadSharedTimerGtk.cpp
r191789 r191852 29 29 #include "MainThreadSharedTimer.h" 30 30 31 #include < wtf/glib/GMainLoopSource.h>31 #include <glib.h> 32 32 33 33 namespace WebCore { 34 34 35 static GMainLoopSource gSharedTimer; 35 MainThreadSharedTimer::MainThreadSharedTimer() 36 : m_timer(RunLoop::main(), this, &MainThreadSharedTimer::fired) 37 { 38 // This is GDK_PRIORITY_REDRAW, but we don't want to depend on GDK here just to use a constant. 39 m_timer.setPriority(G_PRIORITY_HIGH_IDLE + 20); 40 } 36 41 37 42 void MainThreadSharedTimer::setFireInterval(double interval) 38 43 { 39 44 ASSERT(m_firedFunction); 40 41 // This is GDK_PRIORITY_REDRAW, but we don't want to depend on GDK here just to use a constant. 42 static const int priority = G_PRIORITY_HIGH_IDLE + 20; 43 gSharedTimer.scheduleAfterDelay("[WebKit] sharedTimerTimeoutCallback", [this] { fired(); }, 44 std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(interval)), priority); 45 m_timer.startOneShot(interval); 45 46 } 46 47 47 48 void MainThreadSharedTimer::stop() 48 49 { 49 gSharedTimer.cancel();50 m_timer.stop(); 50 51 } 51 52
Note: See TracChangeset
for help on using the changeset viewer.