Title: [183921] trunk/Source/WTF
Revision
183921
Author
zandober...@gmail.com
Date
2015-05-07 01:26:56 -0700 (Thu, 07 May 2015)

Log Message

[GTK] Clean up RunLoop implementation
https://bugs.webkit.org/show_bug.cgi?id=144729

Reviewed by Carlos Garcia Campos.

Clean up the RunLoop implementation for the GTK port,
removing unnecessary methods and using simpler variable names.

Nested GMainLoops in RunLoop::run() are now created for the
RunLoop's GMainContext, and not for the default context (enforced
through the null argument to g_main_loop_new()).

* wtf/RunLoop.h:
* wtf/gtk/RunLoopGtk.cpp:
(WTF::RunLoop::RunLoop):
(WTF::RunLoop::~RunLoop):
(WTF::RunLoop::run):
(WTF::RunLoop::stop):
(WTF::RunLoop::wakeUp):
(WTF::RunLoop::TimerBase::start):
(WTF::RunLoop::innermostLoop): Deleted.
(WTF::RunLoop::pushNestedMainLoop): Deleted.
(WTF::RunLoop::popNestedMainLoop): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (183920 => 183921)


--- trunk/Source/WTF/ChangeLog	2015-05-07 08:09:03 UTC (rev 183920)
+++ trunk/Source/WTF/ChangeLog	2015-05-07 08:26:56 UTC (rev 183921)
@@ -1,3 +1,29 @@
+2015-05-07  Žan Doberšek  <zdober...@igalia.com>
+
+        [GTK] Clean up RunLoop implementation
+        https://bugs.webkit.org/show_bug.cgi?id=144729
+
+        Reviewed by Carlos Garcia Campos.
+
+        Clean up the RunLoop implementation for the GTK port,
+        removing unnecessary methods and using simpler variable names.
+
+        Nested GMainLoops in RunLoop::run() are now created for the
+        RunLoop's GMainContext, and not for the default context (enforced
+        through the null argument to g_main_loop_new()).
+
+        * wtf/RunLoop.h:
+        * wtf/gtk/RunLoopGtk.cpp:
+        (WTF::RunLoop::RunLoop):
+        (WTF::RunLoop::~RunLoop):
+        (WTF::RunLoop::run):
+        (WTF::RunLoop::stop):
+        (WTF::RunLoop::wakeUp):
+        (WTF::RunLoop::TimerBase::start):
+        (WTF::RunLoop::innermostLoop): Deleted.
+        (WTF::RunLoop::pushNestedMainLoop): Deleted.
+        (WTF::RunLoop::popNestedMainLoop): Deleted.
+
 2015-05-05  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] Async operations running in the WorkQueue thread should schedule their sources to the WorkQueue main lopp

Modified: trunk/Source/WTF/wtf/RunLoop.h (183920 => 183921)


--- trunk/Source/WTF/wtf/RunLoop.h	2015-05-07 08:09:03 UTC (rev 183920)
+++ trunk/Source/WTF/wtf/RunLoop.h	2015-05-07 08:26:56 UTC (rev 183921)
@@ -157,12 +157,9 @@
 #elif USE(GLIB)
 public:
     static gboolean queueWork(RunLoop*);
-    GMainLoop* innermostLoop();
-    void pushNestedMainLoop(GMainLoop*);
-    void popNestedMainLoop();
 private:
-    GRefPtr<GMainContext> m_runLoopContext;
-    Vector<GRefPtr<GMainLoop>> m_runLoopMainLoops;
+    GRefPtr<GMainContext> m_mainContext;
+    Vector<GRefPtr<GMainLoop>> m_mainLoops;
 #endif
 };
 

Modified: trunk/Source/WTF/wtf/gtk/RunLoopGtk.cpp (183920 => 183921)


--- trunk/Source/WTF/wtf/gtk/RunLoopGtk.cpp	2015-05-07 08:09:03 UTC (rev 183920)
+++ trunk/Source/WTF/wtf/gtk/RunLoopGtk.cpp	2015-05-07 08:26:56 UTC (rev 183921)
@@ -35,64 +35,47 @@
 RunLoop::RunLoop()
 {
     // g_main_context_default() doesn't add an extra reference.
-    m_runLoopContext = isMainThread() ? g_main_context_default() : adoptGRef(g_main_context_new());
-    ASSERT(m_runLoopContext);
-    GRefPtr<GMainLoop> innermostLoop = adoptGRef(g_main_loop_new(m_runLoopContext.get(), FALSE));
+    m_mainContext = isMainThread() ? g_main_context_default() : adoptGRef(g_main_context_new());
+    ASSERT(m_mainContext);
+    GRefPtr<GMainLoop> innermostLoop = adoptGRef(g_main_loop_new(m_mainContext.get(), FALSE));
     ASSERT(innermostLoop);
-    m_runLoopMainLoops.append(innermostLoop);
+    m_mainLoops.append(innermostLoop);
 }
 
 RunLoop::~RunLoop()
 {
-    for (int i = m_runLoopMainLoops.size() - 1; i >= 0; --i) {
-        if (!g_main_loop_is_running(m_runLoopMainLoops[i].get()))
+    for (int i = m_mainLoops.size() - 1; i >= 0; --i) {
+        if (!g_main_loop_is_running(m_mainLoops[i].get()))
             continue;
-        g_main_loop_quit(m_runLoopMainLoops[i].get());
+        g_main_loop_quit(m_mainLoops[i].get());
     }
 }
 
 void RunLoop::run()
 {
-    RunLoop& mainRunLoop = RunLoop::current();
-    GMainLoop* innermostLoop = mainRunLoop.innermostLoop();
+    RunLoop& runLoop = RunLoop::current();
+
+    // The innermost main loop should always be there.
+    ASSERT(!runLoop.m_mainLoops.isEmpty());
+
+    GMainLoop* innermostLoop = runLoop.m_mainLoops[0].get();
     if (!g_main_loop_is_running(innermostLoop)) {
         g_main_loop_run(innermostLoop);
         return;
     }
 
     // Create and run a nested loop if the innermost one was already running.
-    GMainLoop* nestedMainLoop = g_main_loop_new(0, FALSE);
-    mainRunLoop.pushNestedMainLoop(nestedMainLoop);
+    GMainLoop* nestedMainLoop = g_main_loop_new(runLoop.m_mainContext.get(), FALSE);
+    runLoop.m_mainLoops.append(adoptGRef(nestedMainLoop));
     g_main_loop_run(nestedMainLoop);
-    mainRunLoop.popNestedMainLoop();
+    runLoop.m_mainLoops.removeLast();
 }
 
-GMainLoop* RunLoop::innermostLoop()
-{
-    // The innermost main loop should always be there.
-    ASSERT(!m_runLoopMainLoops.isEmpty());
-    return m_runLoopMainLoops[0].get();
-}
-
-void RunLoop::pushNestedMainLoop(GMainLoop* nestedLoop)
-{
-    // The innermost main loop should always be there.
-    ASSERT(!m_runLoopMainLoops.isEmpty());
-    m_runLoopMainLoops.append(adoptGRef(nestedLoop));
-}
-
-void RunLoop::popNestedMainLoop()
-{
-    // The innermost main loop should always be there.
-    ASSERT(!m_runLoopMainLoops.isEmpty());
-    m_runLoopMainLoops.removeLast();
-}
-
 void RunLoop::stop()
 {
     // The innermost main loop should always be there.
-    ASSERT(!m_runLoopMainLoops.isEmpty());
-    GRefPtr<GMainLoop> lastMainLoop = m_runLoopMainLoops.last();
+    ASSERT(!m_mainLoops.isEmpty());
+    GRefPtr<GMainLoop> lastMainLoop = m_mainLoops.last();
     if (g_main_loop_is_running(lastMainLoop.get()))
         g_main_loop_quit(lastMainLoop.get());
 }
@@ -102,8 +85,8 @@
     RefPtr<RunLoop> runLoop(this);
     GMainLoopSource::scheduleAndDeleteOnDestroy("[WebKit] RunLoop work", std::function<void()>([runLoop] {
         runLoop->performWork();
-    }), G_PRIORITY_DEFAULT, nullptr, m_runLoopContext.get());
-    g_main_context_wakeup(m_runLoopContext.get());
+    }), G_PRIORITY_DEFAULT, nullptr, m_mainContext.get());
+    g_main_context_wakeup(m_mainContext.get());
 }
 
 RunLoop::TimerBase::TimerBase(RunLoop& runLoop)
@@ -119,7 +102,7 @@
 void RunLoop::TimerBase::start(double fireInterval, bool repeat)
 {
     m_timerSource.scheduleAfterDelay("[WebKit] RunLoop::Timer", std::function<bool ()>([this, repeat] { fired(); return repeat; }),
-        std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::duration<double>(fireInterval)), G_PRIORITY_DEFAULT, nullptr, m_runLoop.m_runLoopContext.get());
+        std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::duration<double>(fireInterval)), G_PRIORITY_DEFAULT, nullptr, m_runLoop.m_mainContext.get());
 }
 
 void RunLoop::TimerBase::stop()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to