Changeset 51222 in webkit for trunk/JavaScriptCore/wtf/MainThread.cpp
- Timestamp:
- Nov 19, 2009, 4:53:38 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/MainThread.cpp
r46598 r51222 40 40 MainThreadFunction* function; 41 41 void* context; 42 ThreadCondition* syncFlag; 42 43 43 FunctionWithContext(MainThreadFunction* function = 0, void* context = 0 )44 FunctionWithContext(MainThreadFunction* function = 0, void* context = 0, ThreadCondition* syncFlag = 0) 44 45 : function(function) 45 46 , context(context) 47 , syncFlag(syncFlag) 46 48 { 47 49 } … … 93 95 94 96 invocation.function(invocation.context); 97 if (invocation.syncFlag) 98 invocation.syncFlag->signal(); 95 99 96 100 // If we are running accumulated functions for too long so UI may become unresponsive, we need to … … 118 122 } 119 123 124 void callOnMainThreadAndWait(MainThreadFunction* function, void* context) 125 { 126 ASSERT(function); 127 128 if (isMainThread()) { 129 function(context); 130 return; 131 } 132 133 ThreadCondition syncFlag; 134 Mutex& functionQueueMutex = mainThreadFunctionQueueMutex(); 135 MutexLocker locker(functionQueueMutex); 136 functionQueue().append(FunctionWithContext(function, context, &syncFlag)); 137 if (functionQueue().size() == 1) 138 scheduleDispatchFunctionsOnMainThread(); 139 syncFlag.wait(functionQueueMutex); 140 } 141 120 142 void setMainThreadCallbacksPaused(bool paused) 121 143 {
Note:
See TracChangeset
for help on using the changeset viewer.