Changeset 32000 in webkit for trunk/JavaScriptCore/wtf/ThreadSpecific.h
- Timestamp:
- Apr 17, 2008, 9:04:48 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/ThreadSpecific.h
r31944 r32000 54 54 55 55 #if USE(PTHREADS) || PLATFORM(WIN) 56 struct Data : Noncopyable { 57 Data(T* value, ThreadSpecific<T>* owner) : value(value), owner(owner) {} 58 59 T* value; 60 ThreadSpecific<T>* owner; 61 }; 62 56 63 pthread_key_t m_key; 57 64 #endif … … 74 81 inline T* ThreadSpecific<T>::get() 75 82 { 76 return static_cast<T*>(pthread_getspecific(m_key)); 83 Data* data = static_cast<Data*>(pthread_getspecific(m_key)); 84 return data ? data->value : 0; 77 85 } 78 86 … … 81 89 { 82 90 ASSERT(!get()); 83 pthread_setspecific(m_key, ptr);91 pthread_setspecific(m_key, new Data(ptr, this)); 84 92 } 85 93 … … 87 95 inline void ThreadSpecific<T>::destroy(void* ptr) 88 96 { 89 delete static_cast<T*>(ptr); 97 Data* data = static_cast<Data*>(ptr); 98 pthread_setspecific(data->owner->m_key, 0); 99 delete data->value; 100 delete data; 90 101 } 91 102
Note:
See TracChangeset
for help on using the changeset viewer.