summaryrefslogtreecommitdiff
path: root/framework/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-03-20 15:49:27 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-03-20 17:30:02 +0100
commit4ddb43bcf159f8cff4bb090da218c4f150dceab8 (patch)
treef002cc8e24553caed1a0ed4eb6849c71aa3baaa5 /framework/source
parentaa4e31ab274cdcc53d715d923823adcdadb6be22 (diff)
Turn odd framework::LockHelper::getGlobalLock() into an osl::Mutex
...and extract it to framework::GlobalLock::get(). The old lock was actually effectively two different locks, LockHelper::getGloblaLock() and LockHelper::getGlobalLock().getShareableOslMutex(), and both were used in different places. These places all use the same single osl::Mutex instance now, but hopefully that does not lead to problems (which it shouldn't, given the documentation of LockHelper::getShareableOslMutex: "Sometimes we need a osl- mutex for sharing with our uno helper ... What can we do? We must use a different mutex member :-( I HOPE IT WORKS!"). Of course, the "TODO: This presumable should return the SolarMutex" still applies. Change-Id: I7caea3241d1b70a00272fe1f2214c071ef22cf2c
Diffstat (limited to 'framework/source')
-rw-r--r--framework/source/fwe/classes/actiontriggerpropertyset.cxx8
-rw-r--r--framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx8
-rw-r--r--framework/source/fwi/classes/protocolhandlercache.cxx63
-rw-r--r--framework/source/fwi/threadhelp/lockhelper.cxx40
-rw-r--r--framework/source/helper/statusindicatorfactory.cxx8
-rw-r--r--framework/source/services/desktop.cxx4
-rw-r--r--framework/source/services/frame.cxx11
7 files changed, 45 insertions, 97 deletions
diff --git a/framework/source/fwe/classes/actiontriggerpropertyset.cxx b/framework/source/fwe/classes/actiontriggerpropertyset.cxx
index 6617aeb82c69..8fdfed67e980 100644
--- a/framework/source/fwe/classes/actiontriggerpropertyset.cxx
+++ b/framework/source/fwe/classes/actiontriggerpropertyset.cxx
@@ -201,7 +201,7 @@ void SAL_CALL ActionTriggerPropertySet::setFastPropertyValue_NoBroadcast(
sal_Int32 nHandle, const Any& aValue )
throw( Exception, std::exception )
{
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ ::osl::MutexGuard aGuard( GlobalLock::get() );
// Search for right handle ... and try to set property value.
switch( nHandle )
@@ -231,7 +231,7 @@ throw( Exception, std::exception )
void SAL_CALL ActionTriggerPropertySet::getFastPropertyValue(
Any& aValue, sal_Int32 nHandle ) const
{
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ ::osl::MutexGuard aGuard( GlobalLock::get() );
// Search for right handle ... and try to get property value.
switch( nHandle )
@@ -268,7 +268,7 @@ void SAL_CALL ActionTriggerPropertySet::getFastPropertyValue(
if( pInfoHelper == NULL )
{
// Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ ::osl::MutexGuard aGuard( GlobalLock::get() );
// Control this pointer again, another instance can be faster then these!
if( pInfoHelper == NULL )
{
@@ -294,7 +294,7 @@ throw ( RuntimeException, std::exception )
if( pInfo == NULL )
{
// Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ ::osl::MutexGuard aGuard( GlobalLock::get() );
// 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 6f413c09d727..6fc046f39e27 100644
--- a/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx
+++ b/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx
@@ -178,7 +178,7 @@ void SAL_CALL ActionTriggerSeparatorPropertySet::setFastPropertyValue_NoBroadcas
sal_Int32 nHandle, const Any& aValue )
throw( Exception, std::exception )
{
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ ::osl::MutexGuard aGuard( GlobalLock::get() );
// Search for right handle ... and try to set property value.
switch( nHandle )
@@ -192,7 +192,7 @@ throw( Exception, std::exception )
void SAL_CALL ActionTriggerSeparatorPropertySet::getFastPropertyValue(
Any& aValue, sal_Int32 nHandle ) const
{
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ ::osl::MutexGuard aGuard( GlobalLock::get() );
// Search for right handle ... and try to get property value.
switch( nHandle )
@@ -213,7 +213,7 @@ void SAL_CALL ActionTriggerSeparatorPropertySet::getFastPropertyValue(
if( pInfoHelper == NULL )
{
// Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ ::osl::MutexGuard aGuard( GlobalLock::get() );
// Control this pointer again, another instance can be faster then these!
if( pInfoHelper == NULL )
{
@@ -239,7 +239,7 @@ throw ( RuntimeException, std::exception )
if( pInfo == NULL )
{
// Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ ::osl::MutexGuard aGuard( GlobalLock::get() );
// 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 eaad82c2f239..c90a5c0c4000 100644
--- a/framework/source/fwi/classes/protocolhandlercache.cxx
+++ b/framework/source/fwi/classes/protocolhandlercache.cxx
@@ -25,7 +25,6 @@
#include <classes/protocolhandlercache.hxx>
#include <classes/converter.hxx>
-#include <threadhelp/guard.hxx>
#include <threadhelp/lockhelper.hxx>
#include <tools/wldcrd.hxx>
@@ -81,20 +80,18 @@ HandlerCFGAccess* HandlerCache::m_pConfig = NULL;
*/
HandlerCache::HandlerCache()
{
- /* SAFE */{
- Guard aGlobalLock( LockHelper::getGlobalLock() );
+ osl::MutexGuard g(GlobalLock::get());
- if (m_nRefCount==0)
- {
- m_pHandler = new HandlerHash();
- m_pPattern = new PatternHash();
- m_pConfig = new HandlerCFGAccess(PACKAGENAME_PROTOCOLHANDLER);
- m_pConfig->read(&m_pHandler,&m_pPattern);
- m_pConfig->setCache(this);
- }
+ if (m_nRefCount==0)
+ {
+ m_pHandler = new HandlerHash();
+ m_pPattern = new PatternHash();
+ m_pConfig = new HandlerCFGAccess(PACKAGENAME_PROTOCOLHANDLER);
+ m_pConfig->read(&m_pHandler,&m_pPattern);
+ m_pConfig->setCache(this);
+ }
- ++m_nRefCount;
- /* SAFE */}
+ ++m_nRefCount;
}
/**
@@ -104,25 +101,23 @@ HandlerCache::HandlerCache()
*/
HandlerCache::~HandlerCache()
{
- /* SAFE */{
- Guard aGlobalLock( LockHelper::getGlobalLock() );
+ osl::MutexGuard g(GlobalLock::get());
- if( m_nRefCount==1)
- {
- m_pConfig->setCache(NULL);
- m_pHandler->free();
- m_pPattern->free();
-
- delete m_pConfig;
- delete m_pHandler;
- delete m_pPattern;
- m_pConfig = NULL;
- m_pHandler= NULL;
- m_pPattern= NULL;
- }
+ if( m_nRefCount==1)
+ {
+ m_pConfig->setCache(NULL);
+ m_pHandler->free();
+ m_pPattern->free();
+
+ delete m_pConfig;
+ delete m_pHandler;
+ delete m_pPattern;
+ m_pConfig = NULL;
+ m_pHandler= NULL;
+ m_pPattern= NULL;
+ }
- --m_nRefCount;
- /* SAFE */}
+ --m_nRefCount;
}
/**
@@ -134,7 +129,7 @@ sal_Bool HandlerCache::search( const OUString& sURL, ProtocolHandler* pReturn )
{
sal_Bool bFound = sal_False;
/* SAFE */{
- Guard aReadLock( LockHelper::getGlobalLock() );
+ osl::MutexGuard g(GlobalLock::get());
PatternHash::const_iterator pItem = m_pPattern->findPatternKey(sURL);
if (pItem!=m_pPattern->end())
{
@@ -158,8 +153,7 @@ sal_Bool HandlerCache::search( const css::util::URL& aURL, ProtocolHandler* pRet
void HandlerCache::takeOver(HandlerHash* pHandler, PatternHash* pPattern)
{
- // SAFE ->
- Guard aWriteLock( LockHelper::getGlobalLock() );
+ osl::MutexGuard g(GlobalLock::get());
HandlerHash* pOldHandler = m_pHandler;
PatternHash* pOldPattern = m_pPattern;
@@ -171,9 +165,6 @@ void HandlerCache::takeOver(HandlerHash* pHandler, PatternHash* pPattern)
pOldPattern->free();
delete pOldHandler;
delete pOldPattern;
-
- aWriteLock.unlock();
- // <- SAFE
}
/**
diff --git a/framework/source/fwi/threadhelp/lockhelper.cxx b/framework/source/fwi/threadhelp/lockhelper.cxx
index d341fe6bb5b0..856344342a6e 100644
--- a/framework/source/fwi/threadhelp/lockhelper.cxx
+++ b/framework/source/fwi/threadhelp/lockhelper.cxx
@@ -123,46 +123,6 @@ void LockHelper::release()
}
/*-************************************************************************************************************
- @short return a reference to a static lock helper
- @descr Sometimes we need the global mutex or rw-lock! (e.g. in our own static methods)
- But it's not a good idea to use these global one very often ...
- Thats why we use this little helper method.
- We create our own "class global static" lock.
- It will be created at first call only!
- All other requests use these created one then directly.
-
- @seealso -
-
- @param -
- @return A reference to a static mutex/lock member.
-
- @onerror No error should occur.
-*//*-*************************************************************************************************************/
-LockHelper& LockHelper::getGlobalLock()
-{
- // Initialize static "member" only for one time!
- // Algorithm:
- // a) Start with an invalid lock (NULL pointer)
- // b) If these method first called (lock not already exist!) ...
- // c) ... we must create a new one. Protect follow code with the global mutex -
- // (It must be - we create a static variable!)
- // d) Check pointer again - because ... another instance of our class could be faster then these one!
- // e) Create the new lock and set it for return on static variable.
- // f) Return new created or already existing lock object.
- static LockHelper* pLock = NULL;
- if( pLock == NULL )
- {
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if( pLock == NULL )
- {
- static LockHelper aLock;
- pLock = &aLock;
- }
- }
- return *pLock;
-}
-
-/*-************************************************************************************************************
@short return a reference to shared mutex member
@descr Sometimes we need a osl-mutex for sharing with our uno helper ...
What can we do?
diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx
index 944a5288d732..85a56b8355ad 100644
--- a/framework/source/helper/statusindicatorfactory.cxx
+++ b/framework/source/helper/statusindicatorfactory.cxx
@@ -21,7 +21,7 @@
#include <helper/statusindicatorfactory.hxx>
#include <helper/statusindicator.hxx>
#include <helper/vclstatusindicator.hxx>
-#include <threadhelp/guard.hxx>
+#include <threadhelp/lockhelper.hxx>
#include <services.h>
#include <properties.h>
@@ -531,12 +531,12 @@ void StatusIndicatorFactory::impl_reschedule(sal_Bool bForce)
return;
// SAFE ->
- Guard aGlobalLock(LockHelper::getGlobalLock());
+ osl::ResettableMutexGuard aGlobalLock(GlobalLock::get());
if (m_nInReschedule == 0)
{
++m_nInReschedule;
- aGlobalLock.unlock();
+ aGlobalLock.clear();
// <- SAFE
{
@@ -545,7 +545,7 @@ void StatusIndicatorFactory::impl_reschedule(sal_Bool bForce)
}
// SAFE ->
- aGlobalLock.lock();
+ aGlobalLock.reset();
--m_nInReschedule;
}
}
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 028397db5989..44c24ab20fcb 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -1533,7 +1533,7 @@ void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue ,
if( pInfoHelper == NULL )
{
// Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ ::osl::MutexGuard aGuard( GlobalLock::get() );
// Control this pointer again, another instance can be faster then these!
if( pInfoHelper == NULL )
{
@@ -1581,7 +1581,7 @@ css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL Desktop::getPropert
if( pInfo == NULL )
{
// Ready for multithreading
- ::osl::MutexGuard aGuard( LockHelper::getGlobalLock().getShareableOslMutex() );
+ ::osl::MutexGuard aGuard( GlobalLock::get() );
// 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 6a5090bb2d3b..521e3e756693 100644
--- a/framework/source/services/frame.cxx
+++ b/framework/source/services/frame.cxx
@@ -32,7 +32,7 @@
#include <dispatch/dispatchinformationprovider.hxx>
#include <classes/framecontainer.hxx>
#include <classes/propertysethelper.hxx>
-#include <threadhelp/guard.hxx>
+#include <threadhelp/lockhelper.hxx>
#include <threadhelp/transactionguard.hxx>
#include <threadhelp/transactionbase.hxx>
#include <general.h>
@@ -2700,10 +2700,10 @@ void SAL_CALL Frame::windowShown( const css::lang::EventObject& ) throw(css::uno
if (xDesktopCheck.is())
{
/* STATIC SAFE { */
- Guard aStaticWriteLock( LockHelper::getGlobalLock() );
+ osl::ClearableMutexGuard aStaticWriteLock( GlobalLock::get() );
sal_Bool bMustBeTriggered = bFirstVisibleTask;
bFirstVisibleTask = sal_False;
- aStaticWriteLock.unlock();
+ aStaticWriteLock.clear();
/* } STATIC SAFE */
if (bMustBeTriggered)
@@ -3443,8 +3443,7 @@ 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.
- /* STATIC SAFE { */
- Guard aStaticWriteLock(LockHelper::getGlobalLock());
+ osl::MutexGuard g(GlobalLock::get());
css::uno::Reference< css::frame::XFrame2 > xCloserFrame (m_xCloserFrame.get(), css::uno::UNO_QUERY);
if (xCloserFrame!=xNewCloserFrame)
{
@@ -3454,8 +3453,6 @@ void Frame::impl_checkMenuCloser()
impl_setCloser(xNewCloserFrame, sal_True);
m_xCloserFrame = xNewCloserFrame;
}
- aStaticWriteLock.unlock();
- /* } STATIC SAFE */
}