diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2017-06-06 11:02:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-06 20:58:18 +0200 |
commit | cbcaff7510d557d345c15db97f52633c81939d41 (patch) | |
tree | 745ebaa1a384a290bd408288f542e356a20f9027 /ucbhelper | |
parent | ca8a4a7abc81a53a88fc0daa61447f9562f532f5 (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucbhelper')
-rw-r--r-- | ucbhelper/source/provider/contentidentifier.cxx | 15 | ||||
-rw-r--r-- | ucbhelper/source/provider/interactionrequest.cxx | 99 | ||||
-rw-r--r-- | ucbhelper/source/provider/simplenameclashresolverequest.cxx | 14 |
3 files changed, 27 insertions, 101 deletions
diff --git a/ucbhelper/source/provider/contentidentifier.cxx b/ucbhelper/source/provider/contentidentifier.cxx index 16a682682365..0026ca072c92 100644 --- a/ucbhelper/source/provider/contentidentifier.cxx +++ b/ucbhelper/source/provider/contentidentifier.cxx @@ -27,7 +27,6 @@ #include <ucbhelper/contentidentifier.hxx> #include <cppuhelper/typeprovider.hxx> #include <cppuhelper/queryinterface.hxx> -#include <osl/mutex.hxx> using namespace com::sun::star::uno; using namespace com::sun::star::lang; @@ -128,19 +127,11 @@ ContentIdentifier::getImplementationId() Sequence< css::uno::Type > SAL_CALL ContentIdentifier::getTypes() { - static cppu::OTypeCollection* pCollection = nullptr; - if ( !pCollection ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if ( !pCollection ) - { - static cppu::OTypeCollection collection( + static cppu::OTypeCollection s_aCollection( cppu::UnoType<XTypeProvider>::get(), cppu::UnoType<XContentIdentifier>::get() ); - pCollection = &collection; - } - } - return (*pCollection).getTypes(); + + return s_aCollection.getTypes(); } diff --git a/ucbhelper/source/provider/interactionrequest.cxx b/ucbhelper/source/provider/interactionrequest.cxx index 5738187bdf0f..9f4119c8bdb7 100644 --- a/ucbhelper/source/provider/interactionrequest.cxx +++ b/ucbhelper/source/provider/interactionrequest.cxx @@ -25,7 +25,6 @@ *************************************************************************/ #include <ucbhelper/interactionrequest.hxx> -#include <osl/mutex.hxx> #include <osl/diagnose.h> #include <cppuhelper/typeprovider.hxx> #include <cppuhelper/queryinterface.hxx> @@ -146,19 +145,11 @@ uno::Sequence< sal_Int8 > SAL_CALL InteractionRequest::getImplementationId() // virtual uno::Sequence< uno::Type > SAL_CALL InteractionRequest::getTypes() { - static cppu::OTypeCollection* pCollection = nullptr; - if ( !pCollection ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if ( !pCollection ) - { - static cppu::OTypeCollection collection( + static cppu::OTypeCollection s_aCollection( cppu::UnoType<lang::XTypeProvider>::get(), cppu::UnoType<task::XInteractionRequest>::get() ); - pCollection = &collection; - } - } - return (*pCollection).getTypes(); + + return s_aCollection.getTypes(); } @@ -251,19 +242,11 @@ uno::Sequence< sal_Int8 > SAL_CALL InteractionAbort::getImplementationId() // virtual uno::Sequence< uno::Type > SAL_CALL InteractionAbort::getTypes() { - static cppu::OTypeCollection* pCollection = nullptr; - if ( !pCollection ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if ( !pCollection ) - { - static cppu::OTypeCollection collection( + static cppu::OTypeCollection s_aCollection( cppu::UnoType<lang::XTypeProvider>::get(), cppu::UnoType<task::XInteractionAbort>::get() ); - pCollection = &collection; - } - } - return (*pCollection).getTypes(); + + return s_aCollection.getTypes(); } @@ -326,19 +309,11 @@ uno::Sequence< sal_Int8 > SAL_CALL InteractionRetry::getImplementationId() // virtual uno::Sequence< uno::Type > SAL_CALL InteractionRetry::getTypes() { - static cppu::OTypeCollection* pCollection = nullptr; - if ( !pCollection ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if ( !pCollection ) - { - static cppu::OTypeCollection collection( + static cppu::OTypeCollection s_aCollection( cppu::UnoType<lang::XTypeProvider>::get(), cppu::UnoType<task::XInteractionRetry>::get() ); - pCollection = &collection; - } - } - return (*pCollection).getTypes(); + + return s_aCollection.getTypes(); } @@ -401,19 +376,11 @@ uno::Sequence< sal_Int8 > SAL_CALL InteractionApprove::getImplementationId() // virtual uno::Sequence< uno::Type > SAL_CALL InteractionApprove::getTypes() { - static cppu::OTypeCollection* pCollection = nullptr; - if ( !pCollection ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if ( !pCollection ) - { - static cppu::OTypeCollection collection( + static cppu::OTypeCollection s_aCollection( cppu::UnoType<lang::XTypeProvider>::get(), cppu::UnoType<task::XInteractionApprove>::get() ); - pCollection = &collection; - } - } - return (*pCollection).getTypes(); + + return s_aCollection.getTypes(); } @@ -476,19 +443,11 @@ uno::Sequence< sal_Int8 > SAL_CALL InteractionDisapprove::getImplementationId() // virtual uno::Sequence< uno::Type > SAL_CALL InteractionDisapprove::getTypes() { - static cppu::OTypeCollection* pCollection = nullptr; - if ( !pCollection ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if ( !pCollection ) - { - static cppu::OTypeCollection collection( + static cppu::OTypeCollection s_aCollection( cppu::UnoType<lang::XTypeProvider>::get(), cppu::UnoType<task::XInteractionDisapprove>::get() ); - pCollection = &collection; - } - } - return (*pCollection).getTypes(); + + return s_aCollection.getTypes(); } @@ -553,19 +512,11 @@ InteractionSupplyAuthentication::getImplementationId() // virtual uno::Sequence< uno::Type > SAL_CALL InteractionSupplyAuthentication::getTypes() { - static cppu::OTypeCollection* pCollection = nullptr; - if ( !pCollection ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if ( !pCollection ) - { - static cppu::OTypeCollection collection( + static cppu::OTypeCollection s_aCollection( cppu::UnoType<lang::XTypeProvider>::get(), cppu::UnoType<ucb::XInteractionSupplyAuthentication2>::get() ); - pCollection = &collection; - } - } - return (*pCollection).getTypes(); + + return s_aCollection.getTypes(); } @@ -771,19 +722,11 @@ InteractionReplaceExistingData::getImplementationId() // virtual uno::Sequence< uno::Type > SAL_CALL InteractionReplaceExistingData::getTypes() { - static cppu::OTypeCollection* pCollection = nullptr; - if ( !pCollection ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if ( !pCollection ) - { - static cppu::OTypeCollection collection( + static cppu::OTypeCollection s_aCollection( cppu::UnoType<lang::XTypeProvider>::get(), cppu::UnoType<ucb::XInteractionReplaceExistingData>::get() ); - pCollection = &collection; - } - } - return (*pCollection).getTypes(); + + return s_aCollection.getTypes(); } diff --git a/ucbhelper/source/provider/simplenameclashresolverequest.cxx b/ucbhelper/source/provider/simplenameclashresolverequest.cxx index cd94391ad8c5..668b512ab10d 100644 --- a/ucbhelper/source/provider/simplenameclashresolverequest.cxx +++ b/ucbhelper/source/provider/simplenameclashresolverequest.cxx @@ -105,19 +105,11 @@ uno::Sequence< sal_Int8 > SAL_CALL InteractionSupplyName::getImplementationId() uno::Sequence< uno::Type > SAL_CALL InteractionSupplyName::getTypes() { - static cppu::OTypeCollection* pCollection = nullptr; - if ( !pCollection ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if ( !pCollection ) - { - static cppu::OTypeCollection collection( + static cppu::OTypeCollection s_aCollection( cppu::UnoType<lang::XTypeProvider>::get(), cppu::UnoType<ucb::XInteractionSupplyName>::get() ); - pCollection = &collection; - } - } - return (*pCollection).getTypes(); + + return s_aCollection.getTypes(); } void SAL_CALL InteractionSupplyName::select() |