Changeset 132412 in webkit


Ignore:
Timestamp:
Oct 24, 2012 3:40:27 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

loaderRunLoop() should use synchronization instead of while loop
https://bugs.webkit.org/show_bug.cgi?id=55402

Patch by Jae Hyun Park <jae.park@company100.net> on 2012-10-24
Reviewed by Alexey Proskuryakov.

Originally, loaderRunLoop() sleeps until a thread has started and set
the loaderRunLoopObject static variable. This patch uses
ThreadCondition to synchronize instead of a while loop.

No new tests (No behavior change).

  • platform/network/cf/LoaderRunLoopCF.cpp:

(WebCore::runLoaderThread):
(WebCore::loaderRunLoop):

  • platform/network/cf/LoaderRunLoopCF.h:

(WebCore):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r132411 r132412  
     12012-10-24  Jae Hyun Park  <jae.park@company100.net>
     2
     3        loaderRunLoop() should use synchronization instead of while loop
     4        https://bugs.webkit.org/show_bug.cgi?id=55402
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Originally, loaderRunLoop() sleeps until a thread has started and set
     9        the loaderRunLoopObject static variable. This patch uses
     10        ThreadCondition to synchronize instead of a while loop.
     11
     12        No new tests (No behavior change).
     13
     14        * platform/network/cf/LoaderRunLoopCF.cpp:
     15        (WebCore::runLoaderThread):
     16        (WebCore::loaderRunLoop):
     17        * platform/network/cf/LoaderRunLoopCF.h:
     18        (WebCore):
     19
    1202012-10-24  Sailesh Agrawal  <sail@chromium.org>
    221
  • trunk/Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp

    r108119 r132412  
    3939static CFRunLoopRef loaderRunLoopObject = 0;
    4040
     41static Mutex& loaderRunLoopMutex()
     42{
     43    DEFINE_STATIC_LOCAL(Mutex, mutex, ());
     44    return mutex;
     45}
     46
     47static ThreadCondition& loaderRunLoopCondition()
     48{
     49    DEFINE_STATIC_LOCAL(ThreadCondition, threadCondition, ());
     50    return threadCondition;
     51}
     52
    4153static void emptyPerform(void*)
    4254{
     
    4557static void runLoaderThread(void*)
    4658{
    47     loaderRunLoopObject = CFRunLoopGetCurrent();
     59    {
     60        MutexLocker lock(loaderRunLoopMutex());
     61        loaderRunLoopObject = CFRunLoopGetCurrent();
    4862
    49     // Must add a source to the run loop to prevent CFRunLoopRun() from exiting.
    50     CFRunLoopSourceContext ctxt = {0, (void*)1 /*must be non-NULL*/, 0, 0, 0, 0, 0, 0, 0, emptyPerform};
    51     CFRunLoopSourceRef bogusSource = CFRunLoopSourceCreate(0, 0, &ctxt);
    52     CFRunLoopAddSource(loaderRunLoopObject, bogusSource, kCFRunLoopDefaultMode);
     63        // Must add a source to the run loop to prevent CFRunLoopRun() from exiting.
     64        CFRunLoopSourceContext ctxt = {0, (void*)1 /*must be non-null*/, 0, 0, 0, 0, 0, 0, 0, emptyPerform};
     65        CFRunLoopSourceRef bogusSource = CFRunLoopSourceCreate(0, 0, &ctxt);
     66        CFRunLoopAddSource(loaderRunLoopObject, bogusSource, kCFRunLoopDefaultMode);
     67
     68        loaderRunLoopCondition().signal();
     69    }
    5370
    5471    SInt32 result;
     
    6279{
    6380    ASSERT(isMainThread());
     81
     82    MutexLocker lock(loaderRunLoopMutex());
    6483    if (!loaderRunLoopObject) {
    6584        createThread(runLoaderThread, 0, "WebCore: CFNetwork Loader");
    66         while (!loaderRunLoopObject) {
    67             // FIXME: <http://webkit.org/b/55402> - loaderRunLoop() should use synchronization instead of while loop
    68 #if PLATFORM(WIN)
    69             Sleep(10);
    70 #else
    71             struct timespec sleepTime = { 0, 10 * 1000 * 1000 };
    72             nanosleep(&sleepTime, 0);
    73 #endif
    74         }
     85        loaderRunLoopCondition().wait(loaderRunLoopMutex());
    7586    }
    7687    return loaderRunLoopObject;
Note: See TracChangeset for help on using the changeset viewer.