summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/hierarchy
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2017-06-06 11:02:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-06 20:58:18 +0200
commitcbcaff7510d557d345c15db97f52633c81939d41 (patch)
tree745ebaa1a384a290bd408288f542e356a20f9027 /ucb/source/ucp/hierarchy
parentca8a4a7abc81a53a88fc0daa61447f9562f532f5 (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 'ucb/source/ucp/hierarchy')
-rw-r--r--ucb/source/ucp/hierarchy/hierarchycontent.cxx52
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydatasource.cxx49
2 files changed, 14 insertions, 87 deletions
diff --git a/ucb/source/ucp/hierarchy/hierarchycontent.cxx b/ucb/source/ucp/hierarchy/hierarchycontent.cxx
index 8ff414b5816e..fe1750221fee 100644
--- a/ucb/source/ucp/hierarchy/hierarchycontent.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchycontent.cxx
@@ -37,7 +37,6 @@
*************************************************************************/
#include <osl/diagnose.h>
-#include "osl/doublecheckedlocking.h"
#include <rtl/ustring.h>
#include <rtl/ustring.hxx>
#include <com/sun/star/beans/IllegalTypeException.hpp>
@@ -201,21 +200,9 @@ XTYPEPROVIDER_COMMON_IMPL( HierarchyContent );
// virtual
uno::Sequence< uno::Type > SAL_CALL HierarchyContent::getTypes()
{
- cppu::OTypeCollection * pCollection = nullptr;
-
if ( isFolder() && !isReadOnly() )
{
- 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 ),
@@ -226,29 +213,14 @@ uno::Sequence< uno::Type > SAL_CALL HierarchyContent::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 ),
@@ -259,17 +231,9 @@ uno::Sequence< uno::Type > SAL_CALL HierarchyContent::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();
+ }
}
diff --git a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
index c632656f86c0..63f6a21bf9b0 100644
--- a/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydatasource.cxx
@@ -29,7 +29,6 @@
#include "hierarchydatasource.hxx"
#include <osl/diagnose.h>
-#include "osl/doublecheckedlocking.h"
#include <comphelper/processfactory.hxx>
#include <comphelper/interfacecontainer2.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
@@ -607,49 +606,21 @@ XTYPEPROVIDER_COMMON_IMPL( HierarchyDataAccess );
// virtual
uno::Sequence< uno::Type > SAL_CALL HierarchyDataAccess::getTypes()
{
- cppu::OTypeCollection * pCollection = nullptr;
-
if ( m_bReadOnly )
{
- static cppu::OTypeCollection* pReadOnlyTypes = nullptr;
-
- pCollection = pReadOnlyTypes;
- if ( !pCollection )
- {
- osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
-
- pCollection = pReadOnlyTypes;
- if ( !pCollection )
- {
- static cppu::OTypeCollection aCollection(
+ static cppu::OTypeCollection s_aReadOnlyTypes(
CPPU_TYPE_REF( lang::XTypeProvider ),
CPPU_TYPE_REF( lang::XServiceInfo ),
CPPU_TYPE_REF( lang::XComponent ),
CPPU_TYPE_REF( container::XHierarchicalNameAccess ),
CPPU_TYPE_REF( container::XNameAccess ),
CPPU_TYPE_REF( util::XChangesNotifier ) );
- pCollection = &aCollection;
- OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
- pReadOnlyTypes = pCollection;
- }
- }
- else {
- OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
- }
+
+ return s_aReadOnlyTypes.getTypes();
}
else
{
- static cppu::OTypeCollection* pReadWriteTypes = nullptr;
-
- pCollection = pReadWriteTypes;
- if ( !pCollection )
- {
- osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
-
- pCollection = pReadWriteTypes;
- if ( !pCollection )
- {
- static cppu::OTypeCollection aCollection(
+ static cppu::OTypeCollection s_aReadWriteTypes(
CPPU_TYPE_REF( lang::XTypeProvider ),
CPPU_TYPE_REF( lang::XServiceInfo ),
CPPU_TYPE_REF( lang::XComponent ),
@@ -658,17 +629,9 @@ uno::Sequence< uno::Type > SAL_CALL HierarchyDataAccess::getTypes()
CPPU_TYPE_REF( container::XNameContainer ),
CPPU_TYPE_REF( util::XChangesBatch ),
CPPU_TYPE_REF( util::XChangesNotifier ) );
- pCollection = &aCollection;
- OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
- pReadWriteTypes = pCollection;
- }
- }
- else {
- OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
- }
- }
- return (*pCollection).getTypes();
+ return s_aReadWriteTypes.getTypes();
+ }
}