+ if ( !IsOk() )
+ return;
+
+ // Win32 API doesn't have the equivalent of pthread's destructor, so we
+ // have to keep track of all allocated values and destroy them manually;
+ // ideally we'd do that at thread exit time, but since we could only
+ // do that with wxThread and not otherwise created threads, we do it
+ // here.
+ //
+ // TODO: We should still call destructors for wxTlsKey used in the
+ // thread from wxThread's thread shutdown code, *in addition*
+ // to doing it in ~wxTlsKey.
+ //
+ // NB: No need to lock m_csAllValues, by the time this code is called,
+ // no other thread can be using this key.
+ for ( wxVector<void*>::iterator i = m_allValues.begin();
+ i != m_allValues.end();
+ ++i )
+ {
+ m_destructor(*i);
+ }
+
+ ::TlsFree(m_slot);