summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-04-15 12:50:57 +0200
committerJan Holesovsky <kendy@collabora.com>2014-04-15 13:10:56 +0200
commitdc6175ff1fb317a4536722e2adb5302988316e9a (patch)
treed2cfde89f5751bd516a9c86f1797b4634ccf141b /framework
parent4bc0bd734847160d3eb94d9e49d9b99f2c7c1afc (diff)
Remove LockHelper::getGlobalMutex().
Do what the TODO suggests - change it to SolarMutex in most cases. In some cases it is only there to guard a local static, introduce a local mutex for those. Change-Id: Idc3155818f737b958b36ee9125e2e9e8cb1b91a1
Diffstat (limited to 'framework')
-rw-r--r--framework/Library_fwi.mk1
-rw-r--r--framework/inc/threadhelp/lockhelper.hxx39
-rw-r--r--framework/source/fwe/classes/actiontriggerpropertyset.cxx11
-rw-r--r--framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx11
-rw-r--r--framework/source/fwi/classes/protocolhandlercache.cxx27
-rw-r--r--framework/source/fwi/threadhelp/lockhelper.cxx37
-rw-r--r--framework/source/helper/statusindicatorfactory.cxx11
-rw-r--r--framework/source/services/desktop.cxx9
-rw-r--r--framework/source/services/frame.cxx15
9 files changed, 39 insertions, 122 deletions
diff --git a/framework/Library_fwi.mk b/framework/Library_fwi.mk
index 4c56b77e1869..aaaf0757a61c 100644
--- a/framework/Library_fwi.mk
+++ b/framework/Library_fwi.mk
@@ -57,7 +57,6 @@ $(eval $(call gb_Library_add_exception_objects,fwi,\
framework/source/fwi/helper/shareablemutex \
framework/source/fwi/jobs/configaccess \
framework/source/fwi/jobs/jobconst \
- framework/source/fwi/threadhelp/lockhelper \
framework/source/fwi/threadhelp/transactionmanager \
framework/source/fwi/uielement/constitemcontainer \
framework/source/fwi/uielement/itemcontainer \
diff --git a/framework/inc/threadhelp/lockhelper.hxx b/framework/inc/threadhelp/lockhelper.hxx
deleted file mode 100644
index eb2260a6378a..000000000000
--- a/framework/inc/threadhelp/lockhelper.hxx
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_FRAMEWORK_INC_THREADHELP_LOCKHELPER_HXX
-#define INCLUDED_FRAMEWORK_INC_THREADHELP_LOCKHELPER_HXX
-
-#include <sal/config.h>
-
-#include <fwidllapi.h>
-
-namespace osl { class Mutex; }
-
-namespace framework { namespace LockHelper {
-
-//TODO: This presumable should return the SolarMutex, though it actually returns
-// some independent mutex:
-FWI_DLLPUBLIC osl::Mutex & getGlobalLock();
-
-} }
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/fwe/classes/actiontriggerpropertyset.cxx b/framework/source/fwe/classes/actiontriggerpropertyset.cxx
index 6c345d13fda2..21767273751d 100644
--- a/framework/source/fwe/classes/actiontriggerpropertyset.cxx
+++ b/framework/source/fwe/classes/actiontriggerpropertyset.cxx
@@ -18,7 +18,6 @@
*/
#include <classes/actiontriggerpropertyset.hxx>
-#include <threadhelp/lockhelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <cppuhelper/proptypehlp.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -199,7 +198,7 @@ void SAL_CALL ActionTriggerPropertySet::setFastPropertyValue_NoBroadcast(
sal_Int32 nHandle, const Any& aValue )
throw( Exception, std::exception )
{
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
+ SolarMutexGuard aGuard;
// Search for right handle ... and try to set property value.
switch( nHandle )
@@ -229,7 +228,7 @@ throw( Exception, std::exception )
void SAL_CALL ActionTriggerPropertySet::getFastPropertyValue(
Any& aValue, sal_Int32 nHandle ) const
{
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
+ SolarMutexGuard aGuard;
// Search for right handle ... and try to get property value.
switch( nHandle )
@@ -265,8 +264,7 @@ void SAL_CALL ActionTriggerPropertySet::getFastPropertyValue(
if( pInfoHelper == NULL )
{
- // Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
+ SolarMutexGuard aGuard;
// Control this pointer again, another instance can be faster then these!
if( pInfoHelper == NULL )
{
@@ -291,8 +289,7 @@ throw ( RuntimeException, std::exception )
if( pInfo == NULL )
{
- // Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
+ SolarMutexGuard aGuard;
// Control this pointer again, another instance can be faster then these!
if( pInfo == NULL )
{
diff --git a/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx b/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx
index ba3ce6f3eeea..3090020fadcc 100644
--- a/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx
+++ b/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx
@@ -18,7 +18,6 @@
*/
#include <classes/actiontriggerseparatorpropertyset.hxx>
-#include <threadhelp/lockhelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <cppuhelper/proptypehlp.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -176,7 +175,7 @@ void SAL_CALL ActionTriggerSeparatorPropertySet::setFastPropertyValue_NoBroadcas
sal_Int32 nHandle, const Any& aValue )
throw( Exception, std::exception )
{
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
+ SolarMutexGuard aGuard;
// Search for right handle ... and try to set property value.
switch( nHandle )
@@ -190,7 +189,7 @@ throw( Exception, std::exception )
void SAL_CALL ActionTriggerSeparatorPropertySet::getFastPropertyValue(
Any& aValue, sal_Int32 nHandle ) const
{
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
+ SolarMutexGuard aGuard;
// Search for right handle ... and try to get property value.
switch( nHandle )
@@ -210,8 +209,7 @@ void SAL_CALL ActionTriggerSeparatorPropertySet::getFastPropertyValue(
if( pInfoHelper == NULL )
{
- // Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
+ SolarMutexGuard aGuard;
// Control this pointer again, another instance can be faster then these!
if( pInfoHelper == NULL )
{
@@ -236,8 +234,7 @@ throw ( RuntimeException, std::exception )
if( pInfo == NULL )
{
- // Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
+ SolarMutexGuard aGuard;
// Control this pointer again, another instance can be faster then these!
if( pInfo == NULL )
{
diff --git a/framework/source/fwi/classes/protocolhandlercache.cxx b/framework/source/fwi/classes/protocolhandlercache.cxx
index ff8e032911f2..25e1973db08f 100644
--- a/framework/source/fwi/classes/protocolhandlercache.cxx
+++ b/framework/source/fwi/classes/protocolhandlercache.cxx
@@ -25,11 +25,11 @@
#include <classes/protocolhandlercache.hxx>
#include <classes/converter.hxx>
-#include <threadhelp/lockhelper.hxx>
#include <tools/wldcrd.hxx>
#include <unotools/configpaths.hxx>
#include <rtl/ustrbuf.hxx>
+#include <vcl/svapp.hxx>
namespace framework{
@@ -80,7 +80,7 @@ HandlerCFGAccess* HandlerCache::m_pConfig = NULL;
*/
HandlerCache::HandlerCache()
{
- osl::MutexGuard g(LockHelper::getGlobalLock());
+ SolarMutexGuard aGuard;
if (m_nRefCount==0)
{
@@ -101,7 +101,7 @@ HandlerCache::HandlerCache()
*/
HandlerCache::~HandlerCache()
{
- osl::MutexGuard g(LockHelper::getGlobalLock());
+ SolarMutexGuard aGuard;
if( m_nRefCount==1)
{
@@ -128,15 +128,16 @@ HandlerCache::~HandlerCache()
bool HandlerCache::search( const OUString& sURL, ProtocolHandler* pReturn ) const
{
bool bFound = false;
- /* SAFE */{
- osl::MutexGuard g(LockHelper::getGlobalLock());
- PatternHash::const_iterator pItem = m_pPattern->findPatternKey(sURL);
- if (pItem!=m_pPattern->end())
- {
- *pReturn = (*m_pHandler)[pItem->second];
- bFound = true;
- }
- /* SAFE */}
+
+ SolarMutexGuard aGuard;
+
+ PatternHash::const_iterator pItem = m_pPattern->findPatternKey(sURL);
+ if (pItem!=m_pPattern->end())
+ {
+ *pReturn = (*m_pHandler)[pItem->second];
+ bFound = true;
+ }
+
return bFound;
}
@@ -153,7 +154,7 @@ bool HandlerCache::search( const css::util::URL& aURL, ProtocolHandler* pReturn
void HandlerCache::takeOver(HandlerHash* pHandler, PatternHash* pPattern)
{
- osl::MutexGuard g(LockHelper::getGlobalLock());
+ SolarMutexGuard aGuard;
HandlerHash* pOldHandler = m_pHandler;
PatternHash* pOldPattern = m_pPattern;
diff --git a/framework/source/fwi/threadhelp/lockhelper.cxx b/framework/source/fwi/threadhelp/lockhelper.cxx
deleted file mode 100644
index 89a4a75df64d..000000000000
--- a/framework/source/fwi/threadhelp/lockhelper.cxx
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <sal/config.h>
-
-#include <osl/mutex.hxx>
-#include <rtl/instance.hxx>
-
-#include <threadhelp/lockhelper.hxx>
-
-namespace {
-
-struct GlobalLock: public rtl::Static<osl::Mutex, GlobalLock> {};
-
-}
-
-osl::Mutex & framework::LockHelper::getGlobalLock() {
- return GlobalLock::get();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx
index b1e10a5f8383..f0544ce329df 100644
--- a/framework/source/helper/statusindicatorfactory.cxx
+++ b/framework/source/helper/statusindicatorfactory.cxx
@@ -21,7 +21,6 @@
#include <helper/statusindicatorfactory.hxx>
#include <helper/statusindicator.hxx>
#include <helper/vclstatusindicator.hxx>
-#include <threadhelp/lockhelper.hxx>
#include <services.h>
#include <properties.h>
@@ -49,7 +48,9 @@
namespace framework{
-sal_Int32 StatusIndicatorFactory::m_nInReschedule = 0; /// static counter for rescheduling
+sal_Int32 StatusIndicatorFactory::m_nInReschedule = 0; ///< static counter for rescheduling
+struct RescheduleLock: public rtl::Static<osl::Mutex, RescheduleLock> {}; ///< mutex to guard the m_nInReschedule
+
const char PROGRESS_RESOURCE[] = "private:resource/progressbar/progressbar";
StatusIndicatorFactory::StatusIndicatorFactory(const css::uno::Reference< css::uno::XComponentContext >& xContext)
@@ -515,12 +516,12 @@ void StatusIndicatorFactory::impl_reschedule(bool bForce)
return;
// SAFE ->
- osl::ResettableMutexGuard aGlobalLock(LockHelper::getGlobalLock());
+ osl::ResettableMutexGuard aRescheduleGuard(RescheduleLock::get());
if (m_nInReschedule == 0)
{
++m_nInReschedule;
- aGlobalLock.clear();
+ aRescheduleGuard.clear();
// <- SAFE
{
@@ -529,7 +530,7 @@ void StatusIndicatorFactory::impl_reschedule(bool bForce)
}
// SAFE ->
- aGlobalLock.reset();
+ aRescheduleGuard.reset();
--m_nInReschedule;
}
}
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 49ff8a465fd1..a62456689624 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -28,7 +28,6 @@
#include <dispatch/interceptionhelper.hxx>
#include <classes/taskcreator.hxx>
-#include <threadhelp/lockhelper.hxx>
#include <threadhelp/transactionguard.hxx>
#include <general.h>
#include <properties.h>
@@ -1449,8 +1448,8 @@ void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue ,
if( pInfoHelper == NULL )
{
- // Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
+ SolarMutexGuard aGuard;
+
// Control this pointer again, another instance can be faster then these!
if( pInfoHelper == NULL )
{
@@ -1493,8 +1492,8 @@ css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL Desktop::getPropert
if( pInfo == NULL )
{
- // Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
+ SolarMutexGuard aGuard;
+
// Control this pointer again, another instance can be faster then these!
if( pInfo == NULL )
{
diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx
index cea508058fd4..c76480802ef3 100644
--- a/framework/source/services/frame.cxx
+++ b/framework/source/services/frame.cxx
@@ -32,7 +32,6 @@
#include <dispatch/dispatchinformationprovider.hxx>
#include <classes/framecontainer.hxx>
#include <classes/propertysethelper.hxx>
-#include <threadhelp/lockhelper.hxx>
#include <threadhelp/transactionguard.hxx>
#include <threadhelp/transactionbase.hxx>
#include <general.h>
@@ -2507,6 +2506,7 @@ void SAL_CALL Frame::windowClosing( const css::lang::EventObject& ) throw( css::
void SAL_CALL Frame::windowShown( const css::lang::EventObject& ) throw(css::uno::RuntimeException, std::exception)
{
static bool bFirstVisibleTask = true;
+ static osl::Mutex aFirstVisibleLock;
/* SAFE { */
SolarMutexClearableGuard aReadLock;
@@ -2520,12 +2520,10 @@ void SAL_CALL Frame::windowShown( const css::lang::EventObject& ) throw(css::uno
if (xDesktopCheck.is())
{
- /* STATIC SAFE { */
- osl::ClearableMutexGuard aStaticWriteLock( LockHelper::getGlobalLock() );
- bool bMustBeTriggered = bFirstVisibleTask;
- bFirstVisibleTask = false;
- aStaticWriteLock.clear();
- /* } STATIC SAFE */
+ osl::ClearableMutexGuard aGuard(aFirstVisibleLock);
+ bool bMustBeTriggered = bFirstVisibleTask;
+ bFirstVisibleTask = false;
+ aGuard.clear();
if (bMustBeTriggered)
{
@@ -3216,7 +3214,8 @@ void Frame::impl_checkMenuCloser()
// Look for necessary actions ...
// Only if the closer state must be moved from one frame to another one
// or must be enabled/disabled at all.
- osl::MutexGuard g(LockHelper::getGlobalLock());
+ SolarMutexGuard aGuard;
+
css::uno::Reference< css::frame::XFrame2 > xCloserFrame (m_xCloserFrame.get(), css::uno::UNO_QUERY);
if (xCloserFrame!=xNewCloserFrame)
{