Changeset 40969 in webkit for trunk/JavaScriptCore/wtf/MainThread.cpp
- Timestamp:
- Feb 13, 2009, 1:29:21 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/MainThread.cpp
r40888 r40969 40 40 MainThreadFunction* function; 41 41 void* context; 42 ThreadCondition* syncFlag;43 42 44 FunctionWithContext(MainThreadFunction* function = 0, void* context = 0 , ThreadCondition* syncFlag = 0)43 FunctionWithContext(MainThreadFunction* function = 0, void* context = 0) 45 44 : function(function) 46 45 , context(context) 47 , syncFlag(syncFlag)48 46 { 49 47 } … … 95 93 96 94 invocation.function(invocation.context); 97 if (invocation.syncFlag) 98 invocation.syncFlag->signal(); 99 95 100 96 // If we are running accumulated functions for too long so UI may become unresponsive, we need to 101 97 // yield so the user input can be processed. Otherwise user may not be able to even close the window. … … 122 118 } 123 119 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 conditionMutex;135 bool needToSchedule = false;136 {137 MutexLocker locker(mainThreadFunctionQueueMutex());138 needToSchedule = functionQueue().size() == 0;139 functionQueue().append(FunctionWithContext(function, context, &syncFlag));140 conditionMutex.lock();141 }142 143 if (needToSchedule)144 scheduleDispatchFunctionsOnMainThread();145 syncFlag.wait(conditionMutex);146 }147 148 120 void setMainThreadCallbacksPaused(bool paused) 149 121 {
Note:
See TracChangeset
for help on using the changeset viewer.