Modified: trunk/Source/WebCore/ChangeLog (132411 => 132412)
--- trunk/Source/WebCore/ChangeLog 2012-10-24 22:36:28 UTC (rev 132411)
+++ trunk/Source/WebCore/ChangeLog 2012-10-24 22:40:27 UTC (rev 132412)
@@ -1,3 +1,22 @@
+2012-10-24 Jae Hyun Park <[email protected]>
+
+ loaderRunLoop() should use synchronization instead of while loop
+ https://bugs.webkit.org/show_bug.cgi?id=55402
+
+ 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):
+
2012-10-24 Sailesh Agrawal <[email protected]>
Incorrect keycodes for numpad /, -, +, .
Modified: trunk/Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp (132411 => 132412)
--- trunk/Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp 2012-10-24 22:36:28 UTC (rev 132411)
+++ trunk/Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp 2012-10-24 22:40:27 UTC (rev 132412)
@@ -38,19 +38,36 @@
static CFRunLoopRef loaderRunLoopObject = 0;
+static Mutex& loaderRunLoopMutex()
+{
+ DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+ return mutex;
+}
+
+static ThreadCondition& loaderRunLoopCondition()
+{
+ DEFINE_STATIC_LOCAL(ThreadCondition, threadCondition, ());
+ return threadCondition;
+}
+
static void emptyPerform(void*)
{
}
static void runLoaderThread(void*)
{
- loaderRunLoopObject = CFRunLoopGetCurrent();
+ {
+ MutexLocker lock(loaderRunLoopMutex());
+ loaderRunLoopObject = CFRunLoopGetCurrent();
- // Must add a source to the run loop to prevent CFRunLoopRun() from exiting.
- CFRunLoopSourceContext ctxt = {0, (void*)1 /*must be non-NULL*/, 0, 0, 0, 0, 0, 0, 0, emptyPerform};
- CFRunLoopSourceRef bogusSource = CFRunLoopSourceCreate(0, 0, &ctxt);
- CFRunLoopAddSource(loaderRunLoopObject, bogusSource, kCFRunLoopDefaultMode);
+ // Must add a source to the run loop to prevent CFRunLoopRun() from exiting.
+ CFRunLoopSourceContext ctxt = {0, (void*)1 /*must be non-null*/, 0, 0, 0, 0, 0, 0, 0, emptyPerform};
+ CFRunLoopSourceRef bogusSource = CFRunLoopSourceCreate(0, 0, &ctxt);
+ CFRunLoopAddSource(loaderRunLoopObject, bogusSource, kCFRunLoopDefaultMode);
+ loaderRunLoopCondition().signal();
+ }
+
SInt32 result;
do {
AutodrainedPool pool;
@@ -61,17 +78,11 @@
CFRunLoopRef loaderRunLoop()
{
ASSERT(isMainThread());
+
+ MutexLocker lock(loaderRunLoopMutex());
if (!loaderRunLoopObject) {
createThread(runLoaderThread, 0, "WebCore: CFNetwork Loader");
- while (!loaderRunLoopObject) {
- // FIXME: <http://webkit.org/b/55402> - loaderRunLoop() should use synchronization instead of while loop
-#if PLATFORM(WIN)
- Sleep(10);
-#else
- struct timespec sleepTime = { 0, 10 * 1000 * 1000 };
- nanosleep(&sleepTime, 0);
-#endif
- }
+ loaderRunLoopCondition().wait(loaderRunLoopMutex());
}
return loaderRunLoopObject;
}