diff options
Diffstat (limited to 'src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadSpecific.h')
-rw-r--r-- | src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadSpecific.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadSpecific.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadSpecific.h index 4d5d2f7512..b6f5fd3c8b 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadSpecific.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadSpecific.h @@ -79,10 +79,13 @@ private: #if USE(PTHREADS) || PLATFORM(QT) || PLATFORM(WIN_OS) struct Data : Noncopyable { Data(T* value, ThreadSpecific<T>* owner) : value(value), owner(owner) {} +#if PLATFORM(QT) + ~Data() { owner->destroy(this); } +#endif T* value; ThreadSpecific<T>* owner; -#if !USE(PTHREADS) +#if !USE(PTHREADS) && !PLATFORM(QT) void (*destructor)(void*); #endif }; @@ -136,9 +139,7 @@ inline ThreadSpecific<T>::ThreadSpecific() template<typename T> inline ThreadSpecific<T>::~ThreadSpecific() { - Data* data = static_cast<Data*>(m_key.localData()); - if (data) - data->destructor(data); + // Does not invoke destructor functions. QThreadStorage will do it } template<typename T> @@ -153,7 +154,6 @@ inline void ThreadSpecific<T>::set(T* ptr) { ASSERT(!get()); Data* data = new Data(ptr, this); - data->destructor = &ThreadSpecific<T>::destroy; m_key.setLocalData(data); } @@ -218,21 +218,27 @@ inline void ThreadSpecific<T>::destroy(void* ptr) // Some pthreads implementations zero out the pointer before calling destroy(), so we temporarily reset it. pthread_setspecific(data->owner->m_key, ptr); #endif - +#if PLATFORM(QT) + // See comment as above + data->owner->m_key.setLocalData(data); +#endif + data->value->~T(); fastFree(data->value); #if USE(PTHREADS) pthread_setspecific(data->owner->m_key, 0); #elif PLATFORM(QT) - data->owner->m_key.setLocalData(0); + // Do nothing here #elif PLATFORM(WIN_OS) TlsSetValue(tlsKeys()[data->owner->m_index], 0); #else #error ThreadSpecific is not implemented for this platform. #endif +#if !PLATFORM(QT) delete data; +#endif } template<typename T> |