From cbcaff7510d557d345c15db97f52633c81939d41 Mon Sep 17 00:00:00 2001 From: Jochen Nitschke Date: Tue, 6 Jun 2017 11:02:09 +0200 Subject: ucb: replace double checked locking patterns with thread safe local statics and prefix statics Change-Id: Iaa7c9056847f75612d6cf6c6e44d3896fca734de Reviewed-on: https://gerrit.libreoffice.org/38433 Tested-by: Jenkins Reviewed-by: Noel Grandin --- ucb/source/ucp/package/pkgcontent.cxx | 52 ++++++----------------------------- 1 file changed, 8 insertions(+), 44 deletions(-) (limited to 'ucb/source/ucp/package') diff --git a/ucb/source/ucp/package/pkgcontent.cxx b/ucb/source/ucp/package/pkgcontent.cxx index 72d0ec5acb99..7550d7eef252 100644 --- a/ucb/source/ucp/package/pkgcontent.cxx +++ b/ucb/source/ucp/package/pkgcontent.cxx @@ -24,7 +24,6 @@ *************************************************************************/ #include -#include "osl/doublecheckedlocking.h" #include #include #include @@ -317,21 +316,9 @@ XTYPEPROVIDER_COMMON_IMPL( Content ); // virtual uno::Sequence< uno::Type > SAL_CALL Content::getTypes() { - cppu::OTypeCollection * pCollection = nullptr; - if ( isFolder() ) { - static cppu::OTypeCollection* pFolderTypes = nullptr; - - pCollection = pFolderTypes; - if ( !pCollection ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - - pCollection = pFolderTypes; - if ( !pCollection ) - { - static cppu::OTypeCollection aCollection( + static cppu::OTypeCollection s_aFolderTypes( CPPU_TYPE_REF( lang::XTypeProvider ), CPPU_TYPE_REF( lang::XServiceInfo ), CPPU_TYPE_REF( lang::XComponent ), @@ -342,29 +329,14 @@ uno::Sequence< uno::Type > SAL_CALL Content::getTypes() CPPU_TYPE_REF( beans::XPropertyContainer ), CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), CPPU_TYPE_REF( container::XChild ), - CPPU_TYPE_REF( ucb::XContentCreator ) ); // !! - pCollection = &aCollection; - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - pFolderTypes = pCollection; - } - } - else { - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - } + CPPU_TYPE_REF( ucb::XContentCreator ) ); + + return s_aFolderTypes.getTypes(); + } else { - static cppu::OTypeCollection* pDocumentTypes = nullptr; - - pCollection = pDocumentTypes; - if ( !pCollection ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - - pCollection = pDocumentTypes; - if ( !pCollection ) - { - static cppu::OTypeCollection aCollection( + static cppu::OTypeCollection s_aDocumentTypes( CPPU_TYPE_REF( lang::XTypeProvider ), CPPU_TYPE_REF( lang::XServiceInfo ), CPPU_TYPE_REF( lang::XComponent ), @@ -375,17 +347,9 @@ uno::Sequence< uno::Type > SAL_CALL Content::getTypes() CPPU_TYPE_REF( beans::XPropertyContainer ), CPPU_TYPE_REF( beans::XPropertySetInfoChangeNotifier ), CPPU_TYPE_REF( container::XChild ) ); - pCollection = &aCollection; - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - pDocumentTypes = pCollection; - } - } - else { - OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); - } - } - return (*pCollection).getTypes(); + return s_aDocumentTypes.getTypes(); + } } -- cgit