X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8b73c5318ccc837aff38c0e5a824bc4fd56c75c8..14619f10b0bdb630206607abd0ce0319d45e095a:/include/wx/unix/tls.h diff --git a/include/wx/unix/tls.h b/include/wx/unix/tls.h index 5f5744c164..05f92b7fb9 100644 --- a/include/wx/unix/tls.h +++ b/include/wx/unix/tls.h @@ -21,10 +21,10 @@ class wxTlsKey { public: // ctor allocates a new key and possibly registering a destructor function - // for it (notice that using destructor function is Pthreads-specific and - // not supported in Win32 implementation) - wxTlsKey(void (*destructor)(void *) = NULL) + // for it + wxTlsKey(wxTlsDestructorFunction destructor) { + m_destructor = destructor; if ( pthread_key_create(&m_key, destructor) != 0 ) m_key = 0; } @@ -41,6 +41,10 @@ public: // change the key value, return true if ok bool Set(void *value) { + void *old = Get(); + if ( old ) + m_destructor(old); + return pthread_setspecific(m_key, value) == 0; } @@ -52,9 +56,10 @@ public: } private: + wxTlsDestructorFunction m_destructor; pthread_key_t m_key; - DECLARE_NO_COPY_CLASS(wxTlsKey) + wxDECLARE_NO_COPY_CLASS(wxTlsKey); }; #endif // _WX_UNIX_TLS_H_