bool InitializePoolIndex() { assert(PoolIndex == TLS_INVALID_INDEX); PoolIndex = CreateTLSIndex(); return PoolIndex != TLS_INVALID_INDEX; }
extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) { switch (reason) { case DLL_PROCESS_ATTACH: { #if defined(ANGLE_ENABLE_DEBUG_TRACE) FILE *debug = fopen(TRACE_OUTPUT_FILE, "rt"); if (debug) { fclose(debug); debug = fopen(TRACE_OUTPUT_FILE, "wt"); // Erase if (debug) { fclose(debug); } } #endif currentTLS = CreateTLSIndex(); if (currentTLS == TLS_OUT_OF_INDEXES) { return FALSE; } #ifdef ANGLE_ENABLE_DEBUG_ANNOTATIONS gl::InitializeDebugAnnotations(); #endif } // Fall through to initialize index case DLL_THREAD_ATTACH: { egl::AllocateCurrent(); } break; case DLL_THREAD_DETACH: { egl::DeallocateCurrent(); } break; case DLL_PROCESS_DETACH: { egl::DeallocateCurrent(); DestroyTLSIndex(currentTLS); #ifdef ANGLE_ENABLE_DEBUG_ANNOTATIONS gl::UninitializeDebugAnnotations(); #endif } break; default: break; } return TRUE; }
// Call this exactly once at process startup. bool CreateThreadLocalIndex() { currentTLS = CreateTLSIndex(); if (currentTLS == TLS_INVALID_INDEX) { return false; } return true; }