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 /pyuno/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 'pyuno/source')
-rw-r--r-- | pyuno/source/module/pyuno_module.cxx | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx index 0f08ebc53367..8456abfbfff2 100644 --- a/pyuno/source/module/pyuno_module.cxx +++ b/pyuno/source/module/pyuno_module.cxx @@ -202,26 +202,20 @@ void fillStruct( OUString getLibDir() { - static OUString *pLibDir; - if( !pLibDir ) - { - osl::MutexGuard guard( osl::Mutex::getGlobalMutex() ); - if( ! pLibDir ) - { - static OUString libDir; + static OUString sLibDir = []() { + OUString libDir; - // workarounds the $(ORIGIN) until it is available - if( Module::getUrlFromAddress( - reinterpret_cast< oslGenericFunction >(getLibDir), libDir ) ) - { - libDir = libDir.copy( 0, libDir.lastIndexOf('/') ); - OUString name ( "PYUNOLIBDIR" ); - rtl_bootstrap_set( name.pData, libDir.pData ); - } - pLibDir = &libDir; + // workarounds the $(ORIGIN) until it is available + if (Module::getUrlFromAddress(reinterpret_cast<oslGenericFunction>(getLibDir), libDir)) + { + libDir = libDir.copy(0, libDir.lastIndexOf('/')); + OUString name("PYUNOLIBDIR"); + rtl_bootstrap_set(name.pData, libDir.pData); } - } - return *pLibDir; + return libDir; + }(); + + return sLibDir; } void raisePySystemException( const char * exceptionType, const OUString & message ) |