Changeset 55234 in webkit
- Timestamp:
- Feb 25, 2010, 6:49:12 AM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r55198 r55234 1 2010-02-25 Jochen Eisinger <jochen@chromium.org> 2 3 Reviewed by Jeremy Orlow. 4 5 Make the context that was passed to the ThreadFunction accessible. 6 https://bugs.webkit.org/show_bug.cgi?id=35379 7 8 * wtf/Threading.h: 9 * wtf/ThreadingNone.cpp: 10 (WTF::threadContext): 11 * wtf/ThreadingPthreads.cpp: 12 (WTF::): 13 (WTF::identifierByPthreadHandle): 14 (WTF::establishIdentifierForPthreadHandle): 15 (WTF::pthreadHandleForIdentifier): 16 (WTF::contextForIdentifier): 17 (WTF::createThreadInternal): 18 (WTF::currentThread): 19 (WTF::threadContext): 20 * wtf/ThreadingWin.cpp: 21 (WTF::): 22 (WTF::threadMap): 23 (WTF::storeThreadHandleByIdentifier): 24 (WTF::threadHandleForIdentifier): 25 (WTF::contextForIdentifier): 26 (WTF::createThreadInternal): 27 (WTF::threadContext): 28 1 29 2010-02-24 Oliver Hunt <oliver@apple.com> 2 30 -
trunk/JavaScriptCore/wtf/Threading.h
r55158 r55234 128 128 int waitForThreadCompletion(ThreadIdentifier, void**); 129 129 void detachThread(ThreadIdentifier); 130 void* threadContext(ThreadIdentifier); 130 131 131 132 #if USE(PTHREADS) -
trunk/JavaScriptCore/wtf/ThreadingNone.cpp
r53714 r55234 42 42 ThreadIdentifier currentThread() { return ThreadIdentifier(); } 43 43 bool isMainThread() { return true; } 44 void* threadContext(ThreadIdentifier) { return 0; } 44 45 45 46 Mutex::Mutex() { } -
trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp
r53815 r55234 54 54 namespace WTF { 55 55 56 typedef HashMap<ThreadIdentifier, pthread_t> ThreadMap; 56 typedef struct { 57 pthread_t handle; 58 void* context; 59 } ThreadInfo; 60 61 typedef HashMap<ThreadIdentifier, ThreadInfo> ThreadMap; 57 62 58 63 static Mutex* atomicallyInitializedStaticMutex; … … 106 111 ThreadMap::iterator i = threadMap().begin(); 107 112 for (; i != threadMap().end(); ++i) { 108 if (pthread_equal(i->second , pthreadHandle))113 if (pthread_equal(i->second.handle, pthreadHandle)) 109 114 return i->first; 110 115 } … … 113 118 } 114 119 115 static ThreadIdentifier establishIdentifierForPthreadHandle(const pthread_t& pthreadHandle )120 static ThreadIdentifier establishIdentifierForPthreadHandle(const pthread_t& pthreadHandle, void* context) 116 121 { 117 122 ASSERT(!identifierByPthreadHandle(pthreadHandle)); … … 121 126 static ThreadIdentifier identifierCount = 1; 122 127 123 threadMap().add(identifierCount, pthreadHandle); 128 ThreadInfo info; 129 info.handle = pthreadHandle; 130 info.context = context; 131 threadMap().add(identifierCount, info); 124 132 125 133 return identifierCount++; … … 130 138 MutexLocker locker(threadMapMutex()); 131 139 132 return threadMap().get(id); 133 } 140 return threadMap().get(id).handle; 141 } 142 143 static void* contextForIdentifier(ThreadIdentifier id) 144 { 145 MutexLocker locker(threadMapMutex()); 146 147 return threadMap().get(id).context; 148 } 149 134 150 135 151 void clearPthreadHandleForIdentifier(ThreadIdentifier id) … … 175 191 return 0; 176 192 } 177 return establishIdentifierForPthreadHandle(threadHandle );193 return establishIdentifierForPthreadHandle(threadHandle, data); 178 194 } 179 195 #else … … 186 202 } 187 203 188 return establishIdentifierForPthreadHandle(threadHandle );204 return establishIdentifierForPthreadHandle(threadHandle, data); 189 205 } 190 206 #endif … … 236 252 237 253 // Not a WTF-created thread, ThreadIdentifier is not established yet. 238 id = establishIdentifierForPthreadHandle(pthread_self() );254 id = establishIdentifierForPthreadHandle(pthread_self(), 0); 239 255 ThreadIdentifierData::initialize(id); 240 256 return id; … … 250 266 } 251 267 268 void* threadContext(ThreadIdentifier id) 269 { 270 return contextForIdentifier(id); 271 } 272 252 273 Mutex::Mutex() 253 274 { -
trunk/JavaScriptCore/wtf/ThreadingWin.cpp
r53714 r55234 119 119 #pragma pack(pop) 120 120 121 typedef struct { 122 HANDLE handle; 123 void* context; 124 } ThreadInfo; 125 121 126 void initializeCurrentThreadInternal(const char* szThreadName) 122 127 { … … 166 171 } 167 172 168 static HashMap<DWORD, HANDLE>& threadMap()169 { 170 static HashMap<DWORD, HANDLE> map;173 static HashMap<DWORD, ThreadInfo>& threadMap() 174 { 175 static HashMap<DWORD, ThreadInfo> map; 171 176 return map; 172 177 } 173 178 174 static void storeThreadHandleByIdentifier(DWORD threadID, HANDLE threadHandle )179 static void storeThreadHandleByIdentifier(DWORD threadID, HANDLE threadHandle, void* context) 175 180 { 176 181 MutexLocker locker(threadMapMutex()); 177 182 ASSERT(!threadMap().contains(threadID)); 178 threadMap().add(threadID, threadHandle); 183 ThreadInfo info; 184 info.handle = threadHandle; 185 info.context = context; 186 threadMap().add(threadID, info); 179 187 } 180 188 … … 182 190 { 183 191 MutexLocker locker(threadMapMutex()); 184 return threadMap().get(id); 192 return threadMap().get(id).handle; 193 } 194 195 static void* contextForIdentifier(ThreadIdentifier id) 196 { 197 MutexLocker locker(threadMapMutex()); 198 return threadMap().get(id).context; 185 199 } 186 200 … … 238 252 239 253 threadID = static_cast<ThreadIdentifier>(threadIdentifier); 240 storeThreadHandleByIdentifier(threadIdentifier, threadHandle );254 storeThreadHandleByIdentifier(threadIdentifier, threadHandle, data); 241 255 242 256 return threadID; … … 279 293 { 280 294 return currentThread() == mainThreadIdentifier; 295 } 296 297 void* threadContext(ThreadIdentifier threadID) 298 { 299 return contextForIdentifier(threadID); 281 300 } 282 301
Note:
See TracChangeset
for help on using the changeset viewer.