summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-11-11 20:55:22 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-11-13 07:35:10 +0100
commitec1a54ca6033533a20309f3df5b8b5353bb2b509 (patch)
treebeefa4198d801a907a5503e263ee5ef6a5cbdde1
parente6f2736be82559c513aa07c765e9f6c0dd72072b (diff)
rtl::Static->thread-safe static in OPropertyArrayUsageHelper
Change-Id: I389aed33ec3f814c30fca438ac36af4292b30388 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125118 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/comphelper/proparrhlp.hxx16
-rw-r--r--include/comphelper/servicehelper.hxx1
2 files changed, 8 insertions, 9 deletions
diff --git a/include/comphelper/proparrhlp.hxx b/include/comphelper/proparrhlp.hxx
index a53b718c2697..8520ac58f87d 100644
--- a/include/comphelper/proparrhlp.hxx
+++ b/include/comphelper/proparrhlp.hxx
@@ -24,21 +24,21 @@
#include <cppuhelper/propshlp.hxx>
#include <osl/mutex.hxx>
#include <osl/diagnose.h>
-#include <rtl/instance.hxx>
namespace comphelper
{
-template <typename TYPE> struct OPropertyArrayUsageHelperMutex
- : public rtl::Static< ::osl::Mutex, OPropertyArrayUsageHelperMutex<TYPE> > {};
-
template <class TYPE>
class OPropertyArrayUsageHelper
{
protected:
static sal_Int32 s_nRefCount;
static ::cppu::IPropertyArrayHelper* s_pProps;
-
+ static osl::Mutex& theMutex()
+ {
+ static osl::Mutex SINGLETON;
+ return SINGLETON;
+ }
public:
OPropertyArrayUsageHelper();
virtual ~OPropertyArrayUsageHelper();
@@ -92,14 +92,14 @@ template<class TYPE>
template <class TYPE>
OPropertyArrayUsageHelper<TYPE>::OPropertyArrayUsageHelper()
{
- ::osl::MutexGuard aGuard(OPropertyArrayUsageHelperMutex<TYPE>::get());
+ ::osl::MutexGuard aGuard(theMutex());
++s_nRefCount;
}
template <class TYPE>
OPropertyArrayUsageHelper<TYPE>::~OPropertyArrayUsageHelper()
{
- ::osl::MutexGuard aGuard(OPropertyArrayUsageHelperMutex<TYPE>::get());
+ ::osl::MutexGuard aGuard(theMutex());
OSL_ENSURE(s_nRefCount > 0, "OPropertyArrayUsageHelper::~OPropertyArrayUsageHelper : suspicious call : have a refcount of 0 !");
if (!--s_nRefCount)
{
@@ -114,7 +114,7 @@ template <class TYPE>
OSL_ENSURE(s_nRefCount, "OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !");
if (!s_pProps)
{
- ::osl::MutexGuard aGuard(OPropertyArrayUsageHelperMutex<TYPE>::get());
+ ::osl::MutexGuard aGuard(theMutex());
if (!s_pProps)
{
s_pProps = createArrayHelper();
diff --git a/include/comphelper/servicehelper.hxx b/include/comphelper/servicehelper.hxx
index fa906075e1b6..b2c6bf46d009 100644
--- a/include/comphelper/servicehelper.hxx
+++ b/include/comphelper/servicehelper.hxx
@@ -21,7 +21,6 @@
#define INCLUDED_COMPHELPER_SERVICEHELPER_HXX
#include <rtl/uuid.h>
-#include <rtl/instance.hxx>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/uno/Sequence.hxx>