diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-04 15:28:37 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-04 14:46:01 +0100 |
commit | e128f7806961b391cfb265a1ce009b2e036622ca (patch) | |
tree | eda1097987f07ac6e2f507f898b71ddf929e0635 /cppu/source | |
parent | a2058e7516a01167c2d20ed157500b38db967c64 (diff) |
replace double-checked locking patterns with thread safe local statics
Change-Id: I1bf67196e97411aeecc13ed4f91d1088a315e323
Reviewed-on: https://gerrit.libreoffice.org/62839
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'cppu/source')
-rw-r--r-- | cppu/source/uno/data.cxx | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/cppu/source/uno/data.cxx b/cppu/source/uno/data.cxx index 68d114dc940f..6c93fced581d 100644 --- a/cppu/source/uno/data.cxx +++ b/cppu/source/uno/data.cxx @@ -44,22 +44,19 @@ typelib_TypeDescriptionReference * g_pVoidType = nullptr; void * binuno_queryInterface( void * pUnoI, typelib_TypeDescriptionReference * pDestType ) { // init queryInterface() td - static typelib_TypeDescription * g_pQITD = nullptr; - if (nullptr == g_pQITD) - { - MutexGuard aGuard( Mutex::getGlobalMutex() ); - if (nullptr == g_pQITD) - { - typelib_TypeDescriptionReference * type_XInterface = - * typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE ); - typelib_InterfaceTypeDescription * pTXInterfaceDescr = nullptr; - TYPELIB_DANGER_GET( reinterpret_cast<typelib_TypeDescription **>(&pTXInterfaceDescr), type_XInterface ); - assert(pTXInterfaceDescr->ppAllMembers); - typelib_typedescriptionreference_getDescription( - &g_pQITD, pTXInterfaceDescr->ppAllMembers[ 0 ] ); - TYPELIB_DANGER_RELEASE( &pTXInterfaceDescr->aBase ); - } - } + static typelib_TypeDescription* g_pQITD = []() { + typelib_TypeDescriptionReference* type_XInterface + = *typelib_static_type_getByTypeClass(typelib_TypeClass_INTERFACE); + typelib_InterfaceTypeDescription* pTXInterfaceDescr = nullptr; + TYPELIB_DANGER_GET(reinterpret_cast<typelib_TypeDescription**>(&pTXInterfaceDescr), + type_XInterface); + assert(pTXInterfaceDescr->ppAllMembers); + typelib_TypeDescription* pQITD = nullptr; + typelib_typedescriptionreference_getDescription(&pQITD, + pTXInterfaceDescr->ppAllMembers[0]); + TYPELIB_DANGER_RELEASE(&pTXInterfaceDescr->aBase); + return pQITD; + }(); uno_Any aRet, aExc; uno_Any * pExc = &aExc; |