Changeset 132412 in webkit
- Timestamp:
- Oct 24, 2012 3:40:27 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r132411 r132412 1 2012-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 1 20 2012-10-24 Sailesh Agrawal <sail@chromium.org> 2 21 -
trunk/Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp
r108119 r132412 39 39 static CFRunLoopRef loaderRunLoopObject = 0; 40 40 41 static Mutex& loaderRunLoopMutex() 42 { 43 DEFINE_STATIC_LOCAL(Mutex, mutex, ()); 44 return mutex; 45 } 46 47 static ThreadCondition& loaderRunLoopCondition() 48 { 49 DEFINE_STATIC_LOCAL(ThreadCondition, threadCondition, ()); 50 return threadCondition; 51 } 52 41 53 static void emptyPerform(void*) 42 54 { … … 45 57 static void runLoaderThread(void*) 46 58 { 47 loaderRunLoopObject = CFRunLoopGetCurrent(); 59 { 60 MutexLocker lock(loaderRunLoopMutex()); 61 loaderRunLoopObject = CFRunLoopGetCurrent(); 48 62 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 } 53 70 54 71 SInt32 result; … … 62 79 { 63 80 ASSERT(isMainThread()); 81 82 MutexLocker lock(loaderRunLoopMutex()); 64 83 if (!loaderRunLoopObject) { 65 84 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()); 75 86 } 76 87 return loaderRunLoopObject;
Note: See TracChangeset
for help on using the changeset viewer.