Changeset 42167 in webkit for trunk/JavaScriptCore/wtf/ThreadSpecific.h
- Timestamp:
- Apr 2, 2009, 3:29:24 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/ThreadSpecific.h
r41594 r42167 46 46 #if USE(PTHREADS) 47 47 #include <pthread.h> 48 #elif PLATFORM(QT) 49 #include <QThreadStorage> 48 50 #elif PLATFORM(WIN_OS) 49 51 #include <windows.h> … … 52 54 namespace WTF { 53 55 54 #if !USE(PTHREADS) && PLATFORM(WIN_OS)56 #if !USE(PTHREADS) && !PLATFORM(QT) && PLATFORM(WIN_OS) 55 57 // ThreadSpecificThreadExit should be called each time when a thread is detached. 56 58 // This is done automatically for threads created with WTF::createThread. … … 67 69 68 70 private: 69 #if !USE(PTHREADS) && PLATFORM(WIN_OS)71 #if !USE(PTHREADS) && !PLATFORM(QT) && PLATFORM(WIN_OS) 70 72 friend void ThreadSpecificThreadExit(); 71 73 #endif … … 75 77 void static destroy(void* ptr); 76 78 77 #if USE(PTHREADS) || PLATFORM( WIN_OS)79 #if USE(PTHREADS) || PLATFORM(QT) || PLATFORM(WIN_OS) 78 80 struct Data : Noncopyable { 79 81 Data(T* value, ThreadSpecific<T>* owner) : value(value), owner(owner) {} … … 89 91 #if USE(PTHREADS) 90 92 pthread_key_t m_key; 93 #elif PLATFORM(QT) 94 QThreadStorage<Data*> m_key; 91 95 #elif PLATFORM(WIN_OS) 92 96 int m_index; … … 121 125 ASSERT(!get()); 122 126 pthread_setspecific(m_key, new Data(ptr, this)); 127 } 128 129 #elif PLATFORM(QT) 130 131 template<typename T> 132 inline ThreadSpecific<T>::ThreadSpecific() 133 { 134 } 135 136 template<typename T> 137 inline ThreadSpecific<T>::~ThreadSpecific() 138 { 139 Data* data = static_cast<Data*>(m_key.localData()); 140 if (data) 141 data->destructor(data); 142 } 143 144 template<typename T> 145 inline T* ThreadSpecific<T>::get() 146 { 147 Data* data = static_cast<Data*>(m_key.localData()); 148 return data ? data->value : 0; 149 } 150 151 template<typename T> 152 inline void ThreadSpecific<T>::set(T* ptr) 153 { 154 ASSERT(!get()); 155 Data* data = new Data(ptr, this); 156 data->destructor = &ThreadSpecific<T>::destroy; 157 m_key.setLocalData(data); 123 158 } 124 159 … … 190 225 #if USE(PTHREADS) 191 226 pthread_setspecific(data->owner->m_key, 0); 227 #elif PLATFORM(QT) 228 data->owner->m_key.setLocalData(0); 192 229 #elif PLATFORM(WIN_OS) 193 230 TlsSetValue(tlsKeys()[data->owner->m_index], 0);
Note:
See TracChangeset
for help on using the changeset viewer.