diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2018-06-15 21:18:54 +0200 |
---|---|---|
committer | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2018-06-15 22:20:55 +0200 |
commit | 02a7f9e15a46ead2892f54b9e891a32eeef52deb (patch) | |
tree | 164e62bec0b97b9aa786dd5f203426c1ea7cbc45 /stoc | |
parent | 1b897f16e3ab45d87fe34011fa3bdb2a1680901c (diff) |
stoc: replace double-checked locking with static initializers
Change-Id: I2a36033d0377a58dc27564e903e2c7ce02696206
Reviewed-on: https://gerrit.libreoffice.org/55900
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/source/corereflection/crarray.cxx | 18 | ||||
-rw-r--r-- | stoc/source/corereflection/crbase.cxx | 14 | ||||
-rw-r--r-- | stoc/source/corereflection/crcomp.cxx | 20 | ||||
-rw-r--r-- | stoc/source/corereflection/crefl.cxx | 22 | ||||
-rw-r--r-- | stoc/source/corereflection/crenum.cxx | 20 | ||||
-rw-r--r-- | stoc/source/corereflection/criface.cxx | 38 | ||||
-rw-r--r-- | stoc/source/implementationregistration/implreg.cxx | 14 |
7 files changed, 41 insertions, 105 deletions
diff --git a/stoc/source/corereflection/crarray.cxx b/stoc/source/corereflection/crarray.cxx index 4bdfa4867054..1c6b1692aab1 100644 --- a/stoc/source/corereflection/crarray.cxx +++ b/stoc/source/corereflection/crarray.cxx @@ -52,19 +52,11 @@ void ArrayIdlClassImpl::release() throw() Sequence< Type > ArrayIdlClassImpl::getTypes() { - static ::cppu::OTypeCollection * s_pTypes = nullptr; - if (! s_pTypes) - { - ::osl::MutexGuard aGuard( getMutexAccess() ); - if (! s_pTypes) - { - static ::cppu::OTypeCollection s_aTypes( - cppu::UnoType<XIdlArray>::get(), - IdlClassImpl::getTypes() ); - s_pTypes = &s_aTypes; - } - } - return s_pTypes->getTypes(); + static cppu::OTypeCollection s_aTypes( + cppu::UnoType<XIdlArray>::get(), + IdlClassImpl::getTypes() ); + + return s_aTypes.getTypes(); } Sequence< sal_Int8 > ArrayIdlClassImpl::getImplementationId() diff --git a/stoc/source/corereflection/crbase.cxx b/stoc/source/corereflection/crbase.cxx index c5256cac92f6..6e84e20e20fe 100644 --- a/stoc/source/corereflection/crbase.cxx +++ b/stoc/source/corereflection/crbase.cxx @@ -35,17 +35,9 @@ ClassNameVector g_aClassNames; ::osl::Mutex & getMutexAccess() { - static ::osl::Mutex * s_pMutex = nullptr; - if (! s_pMutex) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if (! s_pMutex) - { - static ::osl::Mutex s_aMutex; - s_pMutex = &s_aMutex; - } - } - return *s_pMutex; + static osl::Mutex s_aMutex; + + return s_aMutex; } diff --git a/stoc/source/corereflection/crcomp.cxx b/stoc/source/corereflection/crcomp.cxx index 01e043144075..acfcf765bb2e 100644 --- a/stoc/source/corereflection/crcomp.cxx +++ b/stoc/source/corereflection/crcomp.cxx @@ -94,20 +94,12 @@ void IdlCompFieldImpl::release() throw() Sequence< Type > IdlCompFieldImpl::getTypes() { - static ::cppu::OTypeCollection * s_pTypes = nullptr; - if (! s_pTypes) - { - ::osl::MutexGuard aGuard( getMutexAccess() ); - if (! s_pTypes) - { - static ::cppu::OTypeCollection s_aTypes( - cppu::UnoType<XIdlField2>::get(), - cppu::UnoType<XIdlField>::get(), - IdlMemberImpl::getTypes() ); - s_pTypes = &s_aTypes; - } - } - return s_pTypes->getTypes(); + static cppu::OTypeCollection s_aTypes( + cppu::UnoType<XIdlField2>::get(), + cppu::UnoType<XIdlField>::get(), + IdlMemberImpl::getTypes() ); + + return s_aTypes.getTypes(); } Sequence< sal_Int8 > IdlCompFieldImpl::getImplementationId() diff --git a/stoc/source/corereflection/crefl.cxx b/stoc/source/corereflection/crefl.cxx index d7d59c769dcc..6d02a8b9bf37 100644 --- a/stoc/source/corereflection/crefl.cxx +++ b/stoc/source/corereflection/crefl.cxx @@ -82,21 +82,13 @@ void IdlReflectionServiceImpl::release() throw() Sequence< Type > IdlReflectionServiceImpl::getTypes() { - static OTypeCollection * s_pTypes = nullptr; - if (! s_pTypes) - { - MutexGuard aGuard( _aComponentMutex ); - if (! s_pTypes) - { - static OTypeCollection s_aTypes( - cppu::UnoType<XIdlReflection>::get(), - cppu::UnoType<XHierarchicalNameAccess>::get(), - cppu::UnoType<XServiceInfo>::get(), - OComponentHelper::getTypes() ); - s_pTypes = &s_aTypes; - } - } - return s_pTypes->getTypes(); + static OTypeCollection s_aTypes( + cppu::UnoType<XIdlReflection>::get(), + cppu::UnoType<XHierarchicalNameAccess>::get(), + cppu::UnoType<XServiceInfo>::get(), + OComponentHelper::getTypes() ); + + return s_aTypes.getTypes(); } Sequence< sal_Int8 > IdlReflectionServiceImpl::getImplementationId() diff --git a/stoc/source/corereflection/crenum.cxx b/stoc/source/corereflection/crenum.cxx index ca090763fd12..54871195fff8 100644 --- a/stoc/source/corereflection/crenum.cxx +++ b/stoc/source/corereflection/crenum.cxx @@ -88,20 +88,12 @@ void IdlEnumFieldImpl::release() throw() Sequence< Type > IdlEnumFieldImpl::getTypes() { - static ::cppu::OTypeCollection * s_pTypes = nullptr; - if (! s_pTypes) - { - ::osl::MutexGuard aGuard( getMutexAccess() ); - if (! s_pTypes) - { - static ::cppu::OTypeCollection s_aTypes( - cppu::UnoType<XIdlField2>::get(), - cppu::UnoType<XIdlField>::get(), - IdlMemberImpl::getTypes() ); - s_pTypes = &s_aTypes; - } - } - return s_pTypes->getTypes(); + static cppu::OTypeCollection s_aTypes( + cppu::UnoType<XIdlField2>::get(), + cppu::UnoType<XIdlField>::get(), + IdlMemberImpl::getTypes() ); + + return s_aTypes.getTypes(); } Sequence< sal_Int8 > IdlEnumFieldImpl::getImplementationId() diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx index 25839f741f5f..c37108081fbe 100644 --- a/stoc/source/corereflection/criface.cxx +++ b/stoc/source/corereflection/criface.cxx @@ -121,20 +121,12 @@ void IdlAttributeFieldImpl::release() throw() Sequence< Type > IdlAttributeFieldImpl::getTypes() { - static ::cppu::OTypeCollection * s_pTypes = nullptr; - if (! s_pTypes) - { - ::osl::MutexGuard aGuard( getMutexAccess() ); - if (! s_pTypes) - { - static ::cppu::OTypeCollection s_aTypes( - cppu::UnoType<XIdlField2>::get(), - cppu::UnoType<XIdlField>::get(), - IdlMemberImpl::getTypes() ); - s_pTypes = &s_aTypes; - } - } - return s_pTypes->getTypes(); + static cppu::OTypeCollection s_aTypes( + cppu::UnoType<XIdlField2>::get(), + cppu::UnoType<XIdlField>::get(), + IdlMemberImpl::getTypes() ); + + return s_aTypes.getTypes(); } Sequence< sal_Int8 > IdlAttributeFieldImpl::getImplementationId() @@ -383,19 +375,11 @@ void IdlInterfaceMethodImpl::release() throw() Sequence< Type > IdlInterfaceMethodImpl::getTypes() { - static ::cppu::OTypeCollection * s_pTypes = nullptr; - if (! s_pTypes) - { - ::osl::MutexGuard aGuard( getMutexAccess() ); - if (! s_pTypes) - { - static ::cppu::OTypeCollection s_aTypes( - cppu::UnoType<XIdlMethod>::get(), - IdlMemberImpl::getTypes() ); - s_pTypes = &s_aTypes; - } - } - return s_pTypes->getTypes(); + static cppu::OTypeCollection s_aTypes( + cppu::UnoType<XIdlMethod>::get(), + IdlMemberImpl::getTypes() ); + + return s_aTypes.getTypes(); } Sequence< sal_Int8 > IdlInterfaceMethodImpl::getImplementationId() diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx index 7dff88085b57..b929972ba441 100644 --- a/stoc/source/implementationregistration/implreg.cxx +++ b/stoc/source/implementationregistration/implreg.cxx @@ -99,17 +99,9 @@ struct StringPool const StringPool &spool() { - static StringPool *pPool = nullptr; - if( ! pPool ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pPool ) - { - static StringPool pool; - pPool = &pool; - } - } - return *pPool; + static StringPool s_pool; + + return s_pool; } |