Changeset 94191 in webkit for trunk/Source/JavaScriptCore/wtf/ThreadingPthreads.cpp
- Timestamp:
- Aug 31, 2011, 8:10:10 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/wtf/ThreadingPthreads.cpp
r92154 r94191 51 51 #endif 52 52 53 #if OS(ANDROID)54 #include "JNIUtility.h"55 #include "ThreadFunctionInvocation.h"56 #include <wtf/OwnPtr.h>57 #include <wtf/PassOwnPtr.h>58 #endif59 60 53 #if OS(MAC_OS_X) && !defined(BUILDING_ON_LEOPARD) 61 54 #include <objc/objc-auto.h> … … 154 147 } 155 148 156 #if OS(ANDROID)157 static void* runThreadWithRegistration(void* arg)158 {159 OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(static_cast<ThreadFunctionInvocation*>(arg));160 JavaVM* vm = JSC::Bindings::getJavaVM();161 JNIEnv* env;162 void* ret = 0;163 if (vm->AttachCurrentThread(&env, 0) == JNI_OK) {164 ret = invocation->function(invocation->data);165 vm->DetachCurrentThread();166 }167 return ret;168 }169 170 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char*)171 {172 pthread_t threadHandle;173 174 // On the Android platform, threads must be registered with the VM before they run.175 OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInvocation(entryPoint, data));176 177 if (pthread_create(&threadHandle, 0, runThreadWithRegistration, invocation.get())) {178 LOG_ERROR("Failed to create pthread at entry point %p with data %p", entryPoint, data);179 return 0;180 }181 182 // The thread will take ownership of invocation.183 invocation.leakPtr();184 185 return establishIdentifierForPthreadHandle(threadHandle);186 }187 #else188 149 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char*) 189 150 { … … 196 157 return establishIdentifierForPthreadHandle(threadHandle); 197 158 } 198 #endif199 159 200 160 void initializeCurrentThreadInternal(const char* threadName)
Note:
See TracChangeset
for help on using the changeset viewer.