Remove newly unused framework::LockHelper class
...and make LockHelper::getGlobalLock() FWI_DLLPUBLIC again (so there's a single such lock, not one per library). Change-Id: I0aed77333dc93cdf1c7dd7b96620fb7a8eb3dd64
This commit is contained in:
@@ -20,68 +20,20 @@
|
|||||||
#ifndef INCLUDED_FRAMEWORK_INC_THREADHELP_LOCKHELPER_HXX
|
#ifndef INCLUDED_FRAMEWORK_INC_THREADHELP_LOCKHELPER_HXX
|
||||||
#define INCLUDED_FRAMEWORK_INC_THREADHELP_LOCKHELPER_HXX
|
#define INCLUDED_FRAMEWORK_INC_THREADHELP_LOCKHELPER_HXX
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <sal/config.h>
|
||||||
#include <osl/mutex.hxx>
|
|
||||||
#include <rtl/instance.hxx>
|
|
||||||
|
|
||||||
#include <comphelper/solarmutex.hxx>
|
|
||||||
#include <fwidllapi.h>
|
#include <fwidllapi.h>
|
||||||
|
|
||||||
namespace framework{
|
namespace osl { class Mutex; }
|
||||||
|
|
||||||
|
namespace framework { namespace LockHelper {
|
||||||
|
|
||||||
//TODO: This presumable should return the SolarMutex, though it actually returns
|
//TODO: This presumable should return the SolarMutex, though it actually returns
|
||||||
// some independent mutex:
|
// some independent mutex:
|
||||||
struct GlobalLock: public rtl::Static<osl::Mutex, GlobalLock> {};
|
FWI_DLLPUBLIC osl::Mutex & getGlobalLock();
|
||||||
|
|
||||||
/*-************************************************************************************************************
|
} }
|
||||||
@short helper to set right lock in right situation
|
|
||||||
@descr This helper support different types of locking:
|
|
||||||
a) no locks - transparent for user!
|
|
||||||
This could be useful for simluation or single threaded environments!
|
|
||||||
b) own mutex
|
|
||||||
An object use his own osl-mutex to be threadsafe. Useful for easy and exclusiv locking.
|
|
||||||
c) solar mutex
|
|
||||||
An object use our solar mutex and will be a part of a greater safed "threadsafe code block".
|
|
||||||
Could be useful for simulation and testing of higher modules!
|
|
||||||
d) fair rw-lock
|
|
||||||
An object use an implementation of a fair rw-lock. This increase granularity of t hreadsafe mechanism
|
|
||||||
and should be used for high performance threadsafe code!
|
|
||||||
|
|
||||||
@devstatus draft
|
#endif
|
||||||
*//*-*************************************************************************************************************/
|
|
||||||
class FWI_DLLPUBLIC LockHelper : private boost::noncopyable
|
|
||||||
{
|
|
||||||
|
|
||||||
// public methods
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
// ctor/dtor
|
|
||||||
|
|
||||||
LockHelper( comphelper::SolarMutex* pSolarMutex = NULL );
|
|
||||||
~LockHelper( );
|
|
||||||
|
|
||||||
void acquire();
|
|
||||||
void release();
|
|
||||||
|
|
||||||
// something else
|
|
||||||
|
|
||||||
::osl::Mutex& getShareableOslMutex( );
|
|
||||||
|
|
||||||
|
|
||||||
// private member
|
|
||||||
// Make some member mutable for using in const functions!
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
mutable comphelper::SolarMutex* m_pSolarMutex ;
|
|
||||||
mutable ::osl::Mutex* m_pShareableOslMutex ;
|
|
||||||
mutable sal_Bool m_bDummySolarMutex ;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace framework
|
|
||||||
|
|
||||||
#endif // INCLUDED_FRAMEWORK_INC_THREADHELP_LOCKHELPER_HXX
|
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -201,7 +201,7 @@ void SAL_CALL ActionTriggerPropertySet::setFastPropertyValue_NoBroadcast(
|
|||||||
sal_Int32 nHandle, const Any& aValue )
|
sal_Int32 nHandle, const Any& aValue )
|
||||||
throw( Exception, std::exception )
|
throw( Exception, std::exception )
|
||||||
{
|
{
|
||||||
::osl::MutexGuard aGuard( GlobalLock::get() );
|
::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
|
||||||
|
|
||||||
// Search for right handle ... and try to set property value.
|
// Search for right handle ... and try to set property value.
|
||||||
switch( nHandle )
|
switch( nHandle )
|
||||||
@@ -231,7 +231,7 @@ throw( Exception, std::exception )
|
|||||||
void SAL_CALL ActionTriggerPropertySet::getFastPropertyValue(
|
void SAL_CALL ActionTriggerPropertySet::getFastPropertyValue(
|
||||||
Any& aValue, sal_Int32 nHandle ) const
|
Any& aValue, sal_Int32 nHandle ) const
|
||||||
{
|
{
|
||||||
::osl::MutexGuard aGuard( GlobalLock::get() );
|
::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
|
||||||
|
|
||||||
// Search for right handle ... and try to get property value.
|
// Search for right handle ... and try to get property value.
|
||||||
switch( nHandle )
|
switch( nHandle )
|
||||||
@@ -268,7 +268,7 @@ void SAL_CALL ActionTriggerPropertySet::getFastPropertyValue(
|
|||||||
if( pInfoHelper == NULL )
|
if( pInfoHelper == NULL )
|
||||||
{
|
{
|
||||||
// Ready for multithreading
|
// Ready for multithreading
|
||||||
::osl::MutexGuard aGuard( GlobalLock::get() );
|
::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
|
||||||
// Control this pointer again, another instance can be faster then these!
|
// Control this pointer again, another instance can be faster then these!
|
||||||
if( pInfoHelper == NULL )
|
if( pInfoHelper == NULL )
|
||||||
{
|
{
|
||||||
@@ -294,7 +294,7 @@ throw ( RuntimeException, std::exception )
|
|||||||
if( pInfo == NULL )
|
if( pInfo == NULL )
|
||||||
{
|
{
|
||||||
// Ready for multithreading
|
// Ready for multithreading
|
||||||
::osl::MutexGuard aGuard( GlobalLock::get() );
|
::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
|
||||||
// Control this pointer again, another instance can be faster then these!
|
// Control this pointer again, another instance can be faster then these!
|
||||||
if( pInfo == NULL )
|
if( pInfo == NULL )
|
||||||
{
|
{
|
||||||
|
@@ -178,7 +178,7 @@ void SAL_CALL ActionTriggerSeparatorPropertySet::setFastPropertyValue_NoBroadcas
|
|||||||
sal_Int32 nHandle, const Any& aValue )
|
sal_Int32 nHandle, const Any& aValue )
|
||||||
throw( Exception, std::exception )
|
throw( Exception, std::exception )
|
||||||
{
|
{
|
||||||
::osl::MutexGuard aGuard( GlobalLock::get() );
|
::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
|
||||||
|
|
||||||
// Search for right handle ... and try to set property value.
|
// Search for right handle ... and try to set property value.
|
||||||
switch( nHandle )
|
switch( nHandle )
|
||||||
@@ -192,7 +192,7 @@ throw( Exception, std::exception )
|
|||||||
void SAL_CALL ActionTriggerSeparatorPropertySet::getFastPropertyValue(
|
void SAL_CALL ActionTriggerSeparatorPropertySet::getFastPropertyValue(
|
||||||
Any& aValue, sal_Int32 nHandle ) const
|
Any& aValue, sal_Int32 nHandle ) const
|
||||||
{
|
{
|
||||||
::osl::MutexGuard aGuard( GlobalLock::get() );
|
::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
|
||||||
|
|
||||||
// Search for right handle ... and try to get property value.
|
// Search for right handle ... and try to get property value.
|
||||||
switch( nHandle )
|
switch( nHandle )
|
||||||
@@ -213,7 +213,7 @@ void SAL_CALL ActionTriggerSeparatorPropertySet::getFastPropertyValue(
|
|||||||
if( pInfoHelper == NULL )
|
if( pInfoHelper == NULL )
|
||||||
{
|
{
|
||||||
// Ready for multithreading
|
// Ready for multithreading
|
||||||
::osl::MutexGuard aGuard( GlobalLock::get() );
|
::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
|
||||||
// Control this pointer again, another instance can be faster then these!
|
// Control this pointer again, another instance can be faster then these!
|
||||||
if( pInfoHelper == NULL )
|
if( pInfoHelper == NULL )
|
||||||
{
|
{
|
||||||
@@ -239,7 +239,7 @@ throw ( RuntimeException, std::exception )
|
|||||||
if( pInfo == NULL )
|
if( pInfo == NULL )
|
||||||
{
|
{
|
||||||
// Ready for multithreading
|
// Ready for multithreading
|
||||||
::osl::MutexGuard aGuard( GlobalLock::get() );
|
::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
|
||||||
// Control this pointer again, another instance can be faster then these!
|
// Control this pointer again, another instance can be faster then these!
|
||||||
if( pInfo == NULL )
|
if( pInfo == NULL )
|
||||||
{
|
{
|
||||||
|
@@ -80,7 +80,7 @@ HandlerCFGAccess* HandlerCache::m_pConfig = NULL;
|
|||||||
*/
|
*/
|
||||||
HandlerCache::HandlerCache()
|
HandlerCache::HandlerCache()
|
||||||
{
|
{
|
||||||
osl::MutexGuard g(GlobalLock::get());
|
osl::MutexGuard g(LockHelper::getGlobalLock());
|
||||||
|
|
||||||
if (m_nRefCount==0)
|
if (m_nRefCount==0)
|
||||||
{
|
{
|
||||||
@@ -101,7 +101,7 @@ HandlerCache::HandlerCache()
|
|||||||
*/
|
*/
|
||||||
HandlerCache::~HandlerCache()
|
HandlerCache::~HandlerCache()
|
||||||
{
|
{
|
||||||
osl::MutexGuard g(GlobalLock::get());
|
osl::MutexGuard g(LockHelper::getGlobalLock());
|
||||||
|
|
||||||
if( m_nRefCount==1)
|
if( m_nRefCount==1)
|
||||||
{
|
{
|
||||||
@@ -129,7 +129,7 @@ sal_Bool HandlerCache::search( const OUString& sURL, ProtocolHandler* pReturn )
|
|||||||
{
|
{
|
||||||
sal_Bool bFound = sal_False;
|
sal_Bool bFound = sal_False;
|
||||||
/* SAFE */{
|
/* SAFE */{
|
||||||
osl::MutexGuard g(GlobalLock::get());
|
osl::MutexGuard g(LockHelper::getGlobalLock());
|
||||||
PatternHash::const_iterator pItem = m_pPattern->findPatternKey(sURL);
|
PatternHash::const_iterator pItem = m_pPattern->findPatternKey(sURL);
|
||||||
if (pItem!=m_pPattern->end())
|
if (pItem!=m_pPattern->end())
|
||||||
{
|
{
|
||||||
@@ -153,7 +153,7 @@ sal_Bool HandlerCache::search( const css::util::URL& aURL, ProtocolHandler* pRet
|
|||||||
|
|
||||||
void HandlerCache::takeOver(HandlerHash* pHandler, PatternHash* pPattern)
|
void HandlerCache::takeOver(HandlerHash* pHandler, PatternHash* pPattern)
|
||||||
{
|
{
|
||||||
osl::MutexGuard g(GlobalLock::get());
|
osl::MutexGuard g(LockHelper::getGlobalLock());
|
||||||
|
|
||||||
HandlerHash* pOldHandler = m_pHandler;
|
HandlerHash* pOldHandler = m_pHandler;
|
||||||
PatternHash* pOldPattern = m_pPattern;
|
PatternHash* pOldPattern = m_pPattern;
|
||||||
|
@@ -17,138 +17,21 @@
|
|||||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
* 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>
|
#include <threadhelp/lockhelper.hxx>
|
||||||
#include <general.h>
|
|
||||||
|
|
||||||
#include <macros/generic.hxx>
|
namespace {
|
||||||
#include "vcl/solarmutex.hxx"
|
|
||||||
|
|
||||||
#include <osl/process.h>
|
struct GlobalLock: public rtl::Static<osl::Mutex, GlobalLock> {};
|
||||||
|
|
||||||
namespace framework{
|
|
||||||
|
|
||||||
/*-************************************************************************************************************
|
|
||||||
@short use ctor to initialize instance
|
|
||||||
|
|
||||||
@seealso class Guard
|
|
||||||
|
|
||||||
@param "rSolarMutex", for some components we must be "vcl-free"! So we can't work with our solar mutex
|
|
||||||
directly. User must set his reference at this instance - so we can work with it!
|
|
||||||
@return -
|
|
||||||
|
|
||||||
@onerror -
|
|
||||||
*//*-*************************************************************************************************************/
|
|
||||||
LockHelper::LockHelper( comphelper::SolarMutex* pSolarMutex )
|
|
||||||
: m_pSolarMutex ( NULL )
|
|
||||||
, m_pShareableOslMutex( NULL )
|
|
||||||
, m_bDummySolarMutex ( sal_False )
|
|
||||||
{
|
|
||||||
if( pSolarMutex == NULL )
|
|
||||||
{
|
|
||||||
m_pSolarMutex = new ::vcl::SolarMutexObject;
|
|
||||||
m_bDummySolarMutex = sal_True;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pSolarMutex = pSolarMutex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-************************************************************************************************************
|
osl::Mutex & framework::LockHelper::getGlobalLock() {
|
||||||
@short default dtor to release safed pointer
|
return GlobalLock::get();
|
||||||
@descr We have created dynamical mutex- or lock-member ... or we hold a pointer to external objects.
|
|
||||||
We must release it!
|
|
||||||
|
|
||||||
@seealso ctor()
|
|
||||||
|
|
||||||
@param -
|
|
||||||
@return -
|
|
||||||
|
|
||||||
@onerror -
|
|
||||||
*//*-*************************************************************************************************************/
|
|
||||||
LockHelper::~LockHelper()
|
|
||||||
{
|
|
||||||
if( m_pShareableOslMutex != NULL )
|
|
||||||
{
|
|
||||||
delete m_pShareableOslMutex;
|
|
||||||
m_pShareableOslMutex = NULL;
|
|
||||||
}
|
|
||||||
if( m_pSolarMutex != NULL )
|
|
||||||
{
|
|
||||||
if (m_bDummySolarMutex)
|
|
||||||
{
|
|
||||||
delete static_cast<vcl::SolarMutexObject*>(m_pSolarMutex);
|
|
||||||
m_bDummySolarMutex = sal_False;
|
|
||||||
}
|
|
||||||
m_pSolarMutex = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-************************************************************************************************************
|
|
||||||
@short set an exclusiv lock
|
|
||||||
@descr We must match this lock call with current set lock type and used lock member.
|
|
||||||
If a mutex should be used - it will be easy ... but if a rw-lock should be used
|
|
||||||
we must simulate it as a write access!
|
|
||||||
|
|
||||||
@attention If a shareable osl mutex exist, he must be used as twice!
|
|
||||||
It's necessary for some cppu-helper classes ...
|
|
||||||
|
|
||||||
@param -
|
|
||||||
@return -
|
|
||||||
|
|
||||||
@onerror -
|
|
||||||
*//*-*************************************************************************************************************/
|
|
||||||
void LockHelper::acquire()
|
|
||||||
{
|
|
||||||
m_pSolarMutex->acquire();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-************************************************************************************************************
|
|
||||||
@short release exclusiv lock
|
|
||||||
@descr We must match this unlock call with current set lock type and used lock member.
|
|
||||||
If a mutex should be used - it will be easy ... but if a rw-lock should be used
|
|
||||||
we must simulate it as a write access!
|
|
||||||
|
|
||||||
@attention If a shareable osl mutex exist, he must be used as twice!
|
|
||||||
It's necessary for some cppu-helper classes ...
|
|
||||||
|
|
||||||
@param -
|
|
||||||
@return -
|
|
||||||
|
|
||||||
@onerror -
|
|
||||||
*//*-*************************************************************************************************************/
|
|
||||||
void LockHelper::release()
|
|
||||||
{
|
|
||||||
m_pSolarMutex->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-************************************************************************************************************
|
|
||||||
@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?
|
|
||||||
We must use a different mutex member :-(
|
|
||||||
I HOPE IT WORKS!
|
|
||||||
|
|
||||||
@seealso -
|
|
||||||
|
|
||||||
@param -
|
|
||||||
@return A reference to a shared mutex.
|
|
||||||
|
|
||||||
@onerror No error should occur.
|
|
||||||
*//*-*************************************************************************************************************/
|
|
||||||
::osl::Mutex& LockHelper::getShareableOslMutex()
|
|
||||||
{
|
|
||||||
if( m_pShareableOslMutex == NULL )
|
|
||||||
{
|
|
||||||
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
|
||||||
if( m_pShareableOslMutex == NULL )
|
|
||||||
{
|
|
||||||
m_pShareableOslMutex = new ::osl::Mutex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return *m_pShareableOslMutex;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace framework
|
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -531,7 +531,7 @@ void StatusIndicatorFactory::impl_reschedule(sal_Bool bForce)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// SAFE ->
|
// SAFE ->
|
||||||
osl::ResettableMutexGuard aGlobalLock(GlobalLock::get());
|
osl::ResettableMutexGuard aGlobalLock(LockHelper::getGlobalLock());
|
||||||
|
|
||||||
if (m_nInReschedule == 0)
|
if (m_nInReschedule == 0)
|
||||||
{
|
{
|
||||||
|
@@ -1533,7 +1533,7 @@ void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue ,
|
|||||||
if( pInfoHelper == NULL )
|
if( pInfoHelper == NULL )
|
||||||
{
|
{
|
||||||
// Ready for multithreading
|
// Ready for multithreading
|
||||||
::osl::MutexGuard aGuard( GlobalLock::get() );
|
::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
|
||||||
// Control this pointer again, another instance can be faster then these!
|
// Control this pointer again, another instance can be faster then these!
|
||||||
if( pInfoHelper == NULL )
|
if( pInfoHelper == NULL )
|
||||||
{
|
{
|
||||||
@@ -1581,7 +1581,7 @@ css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL Desktop::getPropert
|
|||||||
if( pInfo == NULL )
|
if( pInfo == NULL )
|
||||||
{
|
{
|
||||||
// Ready for multithreading
|
// Ready for multithreading
|
||||||
::osl::MutexGuard aGuard( GlobalLock::get() );
|
::osl::MutexGuard aGuard( LockHelper::getGlobalLock() );
|
||||||
// Control this pointer again, another instance can be faster then these!
|
// Control this pointer again, another instance can be faster then these!
|
||||||
if( pInfo == NULL )
|
if( pInfo == NULL )
|
||||||
{
|
{
|
||||||
|
@@ -2700,7 +2700,7 @@ void SAL_CALL Frame::windowShown( const css::lang::EventObject& ) throw(css::uno
|
|||||||
if (xDesktopCheck.is())
|
if (xDesktopCheck.is())
|
||||||
{
|
{
|
||||||
/* STATIC SAFE { */
|
/* STATIC SAFE { */
|
||||||
osl::ClearableMutexGuard aStaticWriteLock( GlobalLock::get() );
|
osl::ClearableMutexGuard aStaticWriteLock( LockHelper::getGlobalLock() );
|
||||||
sal_Bool bMustBeTriggered = bFirstVisibleTask;
|
sal_Bool bMustBeTriggered = bFirstVisibleTask;
|
||||||
bFirstVisibleTask = sal_False;
|
bFirstVisibleTask = sal_False;
|
||||||
aStaticWriteLock.clear();
|
aStaticWriteLock.clear();
|
||||||
@@ -3443,7 +3443,7 @@ void Frame::impl_checkMenuCloser()
|
|||||||
// Look for necessary actions ...
|
// Look for necessary actions ...
|
||||||
// Only if the closer state must be moved from one frame to another one
|
// Only if the closer state must be moved from one frame to another one
|
||||||
// or must be enabled/disabled at all.
|
// or must be enabled/disabled at all.
|
||||||
osl::MutexGuard g(GlobalLock::get());
|
osl::MutexGuard g(LockHelper::getGlobalLock());
|
||||||
css::uno::Reference< css::frame::XFrame2 > xCloserFrame (m_xCloserFrame.get(), css::uno::UNO_QUERY);
|
css::uno::Reference< css::frame::XFrame2 > xCloserFrame (m_xCloserFrame.get(), css::uno::UNO_QUERY);
|
||||||
if (xCloserFrame!=xNewCloserFrame)
|
if (xCloserFrame!=xNewCloserFrame)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user