Kaydet (Commit) 60a77056 authored tarafından Caolán McNamara's avatar Caolán McNamara

use rtl::Static where double-locked pattern used

üst 15642286
...@@ -37,9 +37,9 @@ ...@@ -37,9 +37,9 @@
#include <com/sun/star/drawing/framework/XPane.hpp> #include <com/sun/star/drawing/framework/XPane.hpp>
#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/DisposedException.hpp>
#include <rtl/uuid.h>
#include <toolkit/helper/vclunohelper.hxx> #include <toolkit/helper/vclunohelper.hxx>
#include <comphelper/sequence.hxx> #include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/typeprovider.hxx> #include <cppuhelper/typeprovider.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
...@@ -177,20 +177,14 @@ sal_Bool SAL_CALL ViewShellWrapper::relocateToAnchor ( ...@@ -177,20 +177,14 @@ sal_Bool SAL_CALL ViewShellWrapper::relocateToAnchor (
//----- XUnoTunnel ------------------------------------------------------------ //----- XUnoTunnel ------------------------------------------------------------
namespace
{
class theViewShellWrapperUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theViewShellWrapperUnoTunnelId> {};
}
const Sequence<sal_Int8>& ViewShellWrapper::getUnoTunnelId (void) const Sequence<sal_Int8>& ViewShellWrapper::getUnoTunnelId (void)
{ {
static Sequence<sal_Int8>* pSequence = NULL; return theViewShellWrapperUnoTunnelId::get().getSeq();
if (pSequence == NULL)
{
const ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
if (pSequence == NULL)
{
static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16);
rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True);
pSequence = &aSequence;
}
}
return *pSequence;
} }
......
...@@ -69,27 +69,19 @@ class FocusManager::LinkMap ...@@ -69,27 +69,19 @@ class FocusManager::LinkMap
{ {
}; };
struct FocusManagerCreator
{
FocusManager m_aFocusManager;
};
namespace
{
class theFocusManagerInstance : public rtl::Static< FocusManagerCreator, theFocusManagerInstance> {};
}
FocusManager& FocusManager::Instance (void) FocusManager& FocusManager::Instance (void)
{ {
static FocusManager* spInstance = NULL; return theFocusManagerInstance::get().m_aFocusManager;
if (spInstance == NULL)
{
::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
if (spInstance == NULL)
{
static FocusManager aInstance;
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
spInstance = &aInstance;
}
}
else
{
OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
}
return *spInstance;
} }
......
...@@ -104,6 +104,8 @@ public: ...@@ -104,6 +104,8 @@ public:
bool TransferFocus (::Window* pSource, const KeyCode& rCode); bool TransferFocus (::Window* pSource, const KeyCode& rCode);
private: private:
friend struct FocusManagerCreator;
class LinkMap; class LinkMap;
::std::auto_ptr<LinkMap> mpLinks; ::std::auto_ptr<LinkMap> mpLinks;
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <comphelper/sequence.hxx> #include <comphelper/sequence.hxx>
#include <comphelper/stl_types.hxx> #include <comphelper/stl_types.hxx>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/bootstrap.hxx> #include <cppuhelper/bootstrap.hxx>
...@@ -612,20 +613,14 @@ Reference<XModuleController> SAL_CALL ...@@ -612,20 +613,14 @@ Reference<XModuleController> SAL_CALL
//===== XUnoTunnel ============================================================ //===== XUnoTunnel ============================================================
namespace
{
class theDrawControllerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theDrawControllerUnoTunnelId> {};
}
const Sequence<sal_Int8>& DrawController::getUnoTunnelId (void) const Sequence<sal_Int8>& DrawController::getUnoTunnelId (void)
{ {
static ::com::sun::star::uno::Sequence<sal_Int8>* pSequence = NULL; return theDrawControllerUnoTunnelId::get().getSeq();
if (pSequence == NULL)
{
::osl::Guard< ::osl::Mutex > aGuard (::osl::Mutex::getGlobalMutex());
if (pSequence == NULL)
{
static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16);
rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True);
pSequence = &aSequence;
}
}
return *pSequence;
} }
......
...@@ -313,21 +313,15 @@ void SAL_CALL SdXImpressDocument::release() throw ( ) ...@@ -313,21 +313,15 @@ void SAL_CALL SdXImpressDocument::release() throw ( )
} }
} }
namespace
{
class theSdXImpressDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdXImpressDocumentUnoTunnelId> {};
}
// XUnoTunnel // XUnoTunnel
const ::com::sun::star::uno::Sequence< sal_Int8 > & SdXImpressDocument::getUnoTunnelId() throw() const ::com::sun::star::uno::Sequence< sal_Int8 > & SdXImpressDocument::getUnoTunnelId() throw()
{ {
static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0; return theSdXImpressDocumentUnoTunnelId::get().getSeq();
if( !pSeq )
{
::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
if( !pSeq )
{
static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 );
rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
pSeq = &aSeq;
}
}
return *pSeq;
} }
SdXImpressDocument* SdXImpressDocument::getImplementation( const uno::Reference< uno::XInterface >& xInt ) SdXImpressDocument* SdXImpressDocument::getImplementation( const uno::Reference< uno::XInterface >& xInt )
......
...@@ -339,20 +339,14 @@ const SvxItemPropertySet* ImplGetMasterPagePropertySet( PageKind ePageKind ) ...@@ -339,20 +339,14 @@ const SvxItemPropertySet* ImplGetMasterPagePropertySet( PageKind ePageKind )
return pRet; return pRet;
} }
namespace
{
class theSdGenericDrawPageUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdGenericDrawPageUnoTunnelId> {};
}
const ::com::sun::star::uno::Sequence< sal_Int8 > & SdGenericDrawPage::getUnoTunnelId() throw() const ::com::sun::star::uno::Sequence< sal_Int8 > & SdGenericDrawPage::getUnoTunnelId() throw()
{ {
static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0; return theSdGenericDrawPageUnoTunnelId::get().getSeq();
if( !pSeq )
{
::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
if( !pSeq )
{
static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 );
rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
pSeq = &aSeq;
}
}
return *pSeq;
} }
sal_Int64 SAL_CALL SdGenericDrawPage::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException) sal_Int64 SAL_CALL SdGenericDrawPage::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment