[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 14:24:38 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 98792f2880a0ea1b84d390c328668a0ae65f9318
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 8 00:28:34 2010 +0000

    2010-10-07  Rafael Antognolli  <antognolli at profusion.mobi>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [EFL] Fix shared timers on EFL port - make them thread safe.
            https://bugs.webkit.org/show_bug.cgi?id=47383
    
            Using ecore_timer_add to create a timer from a thread that is
            not the main thread isn't safe. Now we add a pipe that is used
            to request a timer to be added in the main thread.
    
            In order to reduce some delay on timers that are added with a
            very small interval, the timer callback is called immediately
            if the interval is smaller than the mainloop frame time.
    
            No new features, so no tests added.
    
            * platform/efl/SharedTimerEfl.cpp:
            (WebCore::setSharedTimerFiredFunction):
            (WebCore::timerEvent):
            (WebCore::processTimers):
            (WebCore::pipeHandlerCb):
            (WebCore::stopSharedTimer):
            (WebCore::addNewTimer):
            (WebCore::setSharedTimerFireTime):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69358 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f802d98..aff4f7b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-10-07  Rafael Antognolli  <antognolli at profusion.mobi>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [EFL] Fix shared timers on EFL port - make them thread safe.
+        https://bugs.webkit.org/show_bug.cgi?id=47383
+
+        Using ecore_timer_add to create a timer from a thread that is
+        not the main thread isn't safe. Now we add a pipe that is used
+        to request a timer to be added in the main thread.
+
+        In order to reduce some delay on timers that are added with a
+        very small interval, the timer callback is called immediately
+        if the interval is smaller than the mainloop frame time.
+
+        No new features, so no tests added.
+
+        * platform/efl/SharedTimerEfl.cpp:
+        (WebCore::setSharedTimerFiredFunction):
+        (WebCore::timerEvent):
+        (WebCore::processTimers):
+        (WebCore::pipeHandlerCb):
+        (WebCore::stopSharedTimer):
+        (WebCore::addNewTimer):
+        (WebCore::setSharedTimerFireTime):
+
 2010-10-07  James Kozianski  <koz at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/platform/efl/SharedTimerEfl.cpp b/WebCore/platform/efl/SharedTimerEfl.cpp
index 437de64..990d0c8 100644
--- a/WebCore/platform/efl/SharedTimerEfl.cpp
+++ b/WebCore/platform/efl/SharedTimerEfl.cpp
@@ -30,43 +30,97 @@
 #include "SharedTimer.h"
 
 #include <Ecore.h>
+#include <pthread.h>
 #include <stdio.h>
 #include <wtf/Assertions.h>
 #include <wtf/CurrentTime.h>
+#include <wtf/MainThread.h>
 
 namespace WebCore {
 
-static Ecore_Timer *g_sharedTimer = 0;
+static pthread_mutex_t timerMutex = PTHREAD_MUTEX_INITIALIZER;
+static Ecore_Timer *_sharedTimer = 0;
+static Ecore_Pipe *_pipe = 0;
 
-static void (*g_timerFunction)();
+static void (*_timerFunction)();
+
+struct timerOp {
+    double time;
+    unsigned char op; // 0 - add a timer; 1 - del a timer;
+};
 
 void setSharedTimerFiredFunction(void (*func)())
 {
-    g_timerFunction = func;
+    _timerFunction = func;
 }
 
 static Eina_Bool timerEvent(void*)
 {
-    if (g_timerFunction)
-        g_timerFunction();
+    if (_timerFunction)
+        _timerFunction();
+
+    _sharedTimer = 0;
 
     return ECORE_CALLBACK_CANCEL;
 }
 
-void stopSharedTimer()
+void processTimers(struct timerOp *tOp)
 {
-    if (g_sharedTimer) {
-        ecore_timer_del(g_sharedTimer);
-        g_sharedTimer = 0;
+    if (_sharedTimer) {
+        ecore_timer_del(_sharedTimer);
+        _sharedTimer = 0;
     }
+
+    if (tOp->op == 1)
+        return;
+
+    double interval = tOp->time - currentTime();
+
+    if (interval <= ecore_animator_frametime_get()) {
+        if (_timerFunction)
+            _timerFunction();
+        return;
+    }
+
+    _sharedTimer = ecore_timer_add(interval, timerEvent, 0);
 }
 
-void setSharedTimerFireTime(double fireTime)
+void pipeHandlerCb(void *data, void *buffer, unsigned int nbyte)
+{
+    ASSERT(nbyte == sizeof(struct timerOp));
+
+    struct timerOp *tOp = (struct timerOp *)buffer;
+    processTimers(tOp);
+}
+
+void stopSharedTimer()
 {
-    double interval = fireTime - currentTime();
+    struct timerOp tOp;
+    pthread_mutex_lock(&timerMutex);
+    if (!_pipe)
+        _pipe = ecore_pipe_add(pipeHandlerCb, 0);
+    pthread_mutex_unlock(&timerMutex);
 
-    stopSharedTimer();
-    g_sharedTimer = ecore_timer_add(interval, timerEvent, 0);
+    tOp.op = 1;
+    ecore_pipe_write(_pipe, &tOp, sizeof(tOp));
+}
+
+void addNewTimer(double fireTime)
+{
+    struct timerOp tOp;
+    pthread_mutex_lock(&timerMutex);
+    if (!_pipe)
+        _pipe = ecore_pipe_add(pipeHandlerCb, 0);
+    pthread_mutex_unlock(&timerMutex);
+
+    tOp.time = fireTime;
+    tOp.op = 0;
+    ecore_pipe_write(_pipe, &tOp, sizeof(tOp));
+}
+
+void setSharedTimerFireTime(double fireTime)
+{
+    addNewTimer(fireTime);
 }
 
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list