Changeset 55247 in webkit for trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp
- Timestamp:
- Feb 25, 2010, 10:27:45 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp
r55246 r55247 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 {
Note:
See TracChangeset
for help on using the changeset viewer.