LocalStore& LocalStore::inst() { static auto _ = init(); mt_unused(_); LocalStore* local = static_cast<LocalStore*>(TlsGetValue(_index)); if (!local) { //Externally created thread (ex. Main) create(*Thread::createExt()); local = static_cast<LocalStore*>(TlsGetValue(_index)); } assert(local, "Thread local data not created"); return *local; }
/// Get thread local store static LocalStore& inst() { //initializing here solves static order problem static bool _ = init(); mt_unused(_); LocalStore* local = static_cast<LocalStore*>(pthread_getspecific(_key)); if (!local) { //externally created thread (eg. main) create(*Thread::createExt()); local = static_cast<LocalStore*>(pthread_getspecific(_key)); } assert(local, "Thread local data not created"); return *local; }