X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c0c133e13b36a923c65f94499554e432bc3a0daa..a7689c49fe02c0c065facf736ab28b19f5997b7c:/include/wx/unix/tls.h diff --git a/include/wx/unix/tls.h b/include/wx/unix/tls.h index 126ccd2b17..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,6 +56,7 @@ public: } private: + wxTlsDestructorFunction m_destructor; pthread_key_t m_key; wxDECLARE_NO_COPY_CLASS(wxTlsKey);