Remove wxTLS_XXX() macros from wx itself

Still use wxTHREAD_SPECIFIC_DECL as it is defined as nothing when
wxUSE_THREADS==0, but get rid of wxTLS_VALUE and friends.

Also enable wxUSE_STRING_POS_CACHE when wxUSE_UNICODE_UTF8 because the
issues described in the (now also removed) comment shouldn't occur with
the compiler implementation of the thread-specific variables.
This commit is contained in:
Vadim Zeitlin 2022-10-26 02:16:30 +01:00
parent 16a746ec35
commit ed748bd5a8
5 changed files with 10 additions and 21 deletions

View file

@ -48,14 +48,7 @@
// notice that this optimization is well worth using even in debug builds as it
// changes asymptotic complexity of algorithms using indices to iterate over
// wxString back to expected linear from quadratic
//
// also notice that wxTLS_TYPE() (__declspec(thread) in this case) is unsafe to
// use in DLL build under pre-Vista Windows so we disable this code for now, if
// anybody really needs to use UTF-8 build under Windows with this optimization
// it would have to be re-tested and probably corrected
// CS: under OSX release builds the string destructor/cache cleanup sometimes
// crashes, disable until we find the true reason or a better workaround
#if wxUSE_UNICODE_UTF8 && !defined(__WINDOWS__) && !defined(__WXOSX__)
#if wxUSE_UNICODE_UTF8
#define wxUSE_STRING_POS_CACHE 1
#else
#define wxUSE_STRING_POS_CACHE 0
@ -445,8 +438,8 @@ private:
unsigned lastUsed;
};
static wxTLS_TYPE(Cache) ms_cache;
static Cache& GetCache() { return wxTLS_VALUE(ms_cache); }
static wxTHREAD_SPECIFIC_DECL Cache ms_cache;
static Cache& GetCache() { return ms_cache; }
static Cache::Element *GetCacheBegin() { return GetCache().cached; }
static Cache::Element *GetCacheEnd() { return GetCacheBegin() + Cache::SIZE; }

View file

@ -81,7 +81,7 @@ const size_t wxString::npos = (size_t) -1;
#if wxUSE_STRING_POS_CACHE
wxTLS_TYPE(wxString::Cache) wxString::ms_cache;
wxTHREAD_SPECIFIC_DECL wxString::Cache wxString::ms_cache;
// 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

View file

@ -45,14 +45,14 @@ inline wxAllThreadInfos& GetAllThreadInfos()
}
// Pointer to the current thread's instance
inline wxTLS_TYPE_REF(wxThreadSpecificInfo*) GetThisThreadInfo()
inline wxThreadSpecificInfo*& GetThisThreadInfo()
{
static wxTLS_TYPE(wxThreadSpecificInfo*) s_thisThreadInfo;
static wxTHREAD_SPECIFIC_DECL wxThreadSpecificInfo* s_thisThreadInfo;
return s_thisThreadInfo;
}
#define wxTHIS_THREAD_INFO wxTLS_VALUE(GetThisThreadInfo())
#define wxTHIS_THREAD_INFO GetThisThreadInfo()
} // anonymous namespace

View file

@ -175,8 +175,7 @@ BENCHMARK_FUNC(BoostTLS)
BENCHMARK_FUNC(wxTLS)
{
static wxTLS_TYPE(int) s_globalVar;
#define s_global wxTLS_VALUE(s_globalVar)
static wxTHREAD_SPECIFIC_DECL int s_global;
for ( int n = 0; n < NUM_ITER; n++ )
{

View file

@ -35,11 +35,8 @@ struct PerThreadData
int number;
};
wxTLS_TYPE(PerThreadData) gs_threadDataVar;
#define gs_threadData wxTLS_VALUE(gs_threadDataVar)
wxTLS_TYPE(int) gs_threadIntVar;
#define gs_threadInt wxTLS_VALUE(gs_threadIntVar)
wxTHREAD_SPECIFIC_DECL PerThreadData gs_threadData;
wxTHREAD_SPECIFIC_DECL int gs_threadInt;
// ----------------------------------------------------------------------------
// test thread