summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-11-04 15:28:37 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-11-04 14:46:01 +0100
commite128f7806961b391cfb265a1ce009b2e036622ca (patch)
treeeda1097987f07ac6e2f507f898b71ddf929e0635 /pyuno
parenta2058e7516a01167c2d20ed157500b38db967c64 (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')
-rw-r--r--pyuno/source/module/pyuno_module.cxx30
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 )