Changeset 74975 in webkit for trunk/Source/JavaScriptCore/wtf/ThreadingPthreads.cpp
- Timestamp:
- Jan 4, 2011, 10:56:18 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/wtf/ThreadingPthreads.cpp
r68209 r74975 51 51 #if OS(ANDROID) 52 52 #include "JNIUtility.h" 53 #include "ThreadFunctionInvocation.h" 54 #include <wtf/OwnPtr.h> 53 55 #endif 54 56 … … 137 139 138 140 #if OS(ANDROID) 139 // On the Android platform, threads must be registered with the VM before they run.140 struct ThreadData {141 ThreadFunction entryPoint;142 void* arg;143 };144 145 141 static void* runThreadWithRegistration(void* arg) 146 142 { 147 ThreadData* data = static_cast<ThreadData*>(arg);143 OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(static_cast<ThreadFunctionInvocation*>(arg)); 148 144 JavaVM* vm = JSC::Bindings::getJavaVM(); 149 145 JNIEnv* env; 150 146 void* ret = 0; 151 147 if (vm->AttachCurrentThread(&env, 0) == JNI_OK) { 152 ret = data->entryPoint(data->arg);148 ret = invocation->function(invocation.data); 153 149 vm->DetachCurrentThread(); 154 150 } 155 delete data;156 151 return ret; 157 152 } … … 160 155 { 161 156 pthread_t threadHandle; 162 ThreadData* threadData = new ThreadData(); 163 threadData->entryPoint = entryPoint;164 threadData->arg = data;165 166 if (pthread_create(&threadHandle, 0, runThreadWithRegistration, static_cast<void*>(threadData))) {157 158 // On the Android platform, threads must be registered with the VM before they run. 159 OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInvocation(entryPoint, data)); 160 161 if (pthread_create(&threadHandle, 0, runThreadWithRegistration, invocation.get())) { 167 162 LOG_ERROR("Failed to create pthread at entry point %p with data %p", entryPoint, data); 168 delete threadData;169 163 return 0; 170 164 } 165 166 // The thread will take ownership of invocation. 167 invocation.leakPtr(); 168 171 169 return establishIdentifierForPthreadHandle(threadHandle); 172 170 }
Note:
See TracChangeset
for help on using the changeset viewer.