void CTLSStorageInstance::FreeStorageKey(const HTLSKEYVALUE &hkvStorageKey) { #if _OU_TARGET_OS == _OU_TARGET_OS_WINDOWS DWORD dwTlsIndex = (DWORD)(size_t)(HTLSKEYVALUE::value_type)hkvStorageKey; OU_ASSERT(dwTlsIndex != TLS_OUT_OF_INDEXES); BOOL bIndexFreeingResult = ::TlsFree(dwTlsIndex); OU_VERIFY(bIndexFreeingResult); #else // #if _OU_TARGET_OS != _OU_TARGET_OS_WINDOWS pthread_key_t pkThreadKey = (pthread_key_t)(size_t)(HTLSKEYVALUE::value_type)hkvStorageKey; int iKeyDeletionResult = pthread_key_delete(pkThreadKey); OU_VERIFY(iKeyDeletionResult == EOK); #endif // #if _OU_TARGET_OS == ... }
void CTLSStorageArray::FreeStorageThreadHandle(unsigned int nBlockIndex) { HANDLE hExistingThreadHandle = GetBlockThreadHandle(nBlockIndex); if (hExistingThreadHandle != INVALID_HANDLE_VALUE) { BOOL bHandleCloseResult = ::CloseHandle(hExistingThreadHandle); OU_VERIFY(bHandleCloseResult); // Closing handle should normally succeed SetBlockThreadHandle(nBlockIndex, INVALID_HANDLE_VALUE); } }
static bool CreateAtomicMutexes() { bool bResult = false; pthread_mutexattr_t maMutexAttributes; int iAttrInitResult = pthread_mutexattr_init(&maMutexAttributes); if (iAttrInitResult == EOK) { bResult = CreateAtomicMutexesWithAttributes(&maMutexAttributes); int iAttrDestroyResult = pthread_mutexattr_destroy(&maMutexAttributes); OU_VERIFY(iAttrDestroyResult == EOK); // Ignore error } return bResult; }
void CTLSStorageInstance::Finit() { CTLSStorageArray *psaStorageArrayList = GetStorageArrayList(); if (psaStorageArrayList) { FreeStorageArrayList(psaStorageArrayList); bool bListClearingResult = TrySettingStorageArrayList(NULL, psaStorageArrayList); // It could be assigned directly, but I just do not want to add an extra method OU_VERIFY(bListClearingResult); } if (GetStorageKeyValidFlag()) { const HTLSKEYVALUE &hkvStorageKey = GetStorageKey(); FreeStorageKey(hkvStorageKey); ResetStorageKeyValidFlag(); } }