const size_t wxString::npos = (size_t) -1;
#if wxUSE_STRING_POS_CACHE
-wxTLS_TYPE(wxString::Cache) wxString::ms_cache;
+
+struct wxStrCacheInitializer
+{
+ wxStrCacheInitializer()
+ {
+ // calling this function triggers s_cache initialization in it, and
+ // from now on it becomes safe to call from multiple threads
+ wxString::GetCache();
+ }
+};
+
+static wxStrCacheInitializer gs_stringCacheInit;
// gdb seems to be unable to display thread-local variables correctly, at least
// not my 6.4.98 version under amd64, so provide this debugging helper to do it
#ifdef __WXDEBUG__
+namespace
+{
+
struct wxStrCacheDumper
{
static void ShowAll()
for ( unsigned n = 0; n < wxString::Cache::SIZE; n++ )
{
const wxString::Cache::Element&
- c = wxString::ms_cache.cached[n];
+ c = wxString::GetCacheBegin()[n];
printf("\t%u%s\t%p: pos=(%lu, %lu), len=%ld\n",
n,
- n == wxString::ms_cache.lastUsed ? " [*]" : "",
+ n == wxString::LastUsedCacheElement() ? " [*]" : "",
c.str,
(unsigned long)c.pos,
(unsigned long)c.impl,
}
};
+} // anonymous namespace
+
void wxDumpStrCache() { wxStrCacheDumper::ShowAll(); }
#endif // __WXDEBUG__