summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--comphelper/source/misc/solarmutex.cxx25
-rw-r--r--include/comphelper/solarmutex.hxx17
-rw-r--r--include/tools/solarmutex.hxx2
-rw-r--r--tools/source/misc/solarmutex.cxx9
-rw-r--r--unotools/source/config/configitem.cxx8
-rw-r--r--vcl/generic/app/geninst.cxx7
-rw-r--r--vcl/osx/salinst.cxx6
-rw-r--r--vcl/win/source/app/salinst.cxx6
8 files changed, 53 insertions, 27 deletions
diff --git a/comphelper/source/misc/solarmutex.cxx b/comphelper/source/misc/solarmutex.cxx
index 0eecac8c37a1..1d2375440804 100644
--- a/comphelper/source/misc/solarmutex.cxx
+++ b/comphelper/source/misc/solarmutex.cxx
@@ -18,11 +18,30 @@
*/
#include <sal/config.h>
-
+#include <assert.h>
#include <comphelper/solarmutex.hxx>
-comphelper::SolarMutex::SolarMutex() {}
+namespace comphelper {
+
+SolarMutex::SolarMutex() {}
+
+SolarMutex::~SolarMutex() {}
+
+namespace {
+ static SolarMutex* pSolarMutex = 0;
+}
+
+void SolarMutex::setSolarMutex( SolarMutex *pMutex )
+{
+ assert((pMutex && !pSolarMutex) || !pMutex);
+ pSolarMutex = pMutex;
+}
+
+SolarMutex *SolarMutex::get()
+{
+ return pSolarMutex;
+}
-comphelper::SolarMutex::~SolarMutex() {}
+} // namespace comphelper
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/solarmutex.hxx b/include/comphelper/solarmutex.hxx
index 3b66a005370c..c50eba29dcda 100644
--- a/include/comphelper/solarmutex.hxx
+++ b/include/comphelper/solarmutex.hxx
@@ -26,8 +26,15 @@
namespace comphelper {
-/** SolarMutex interface, needed for Application::GetSolarMutex().
-*/
+/**
+ * Abstract SolarMutex interface, needed for VCL's
+ * Application::GetSolarMutex().
+ *
+ * The SolarMutex is the one big recursive code lock used
+ * to protect the vast majority of the LibreOffice code-base,
+ * in particular anything that is graphical and the cores of
+ * the applications.
+ */
class COMPHELPER_DLLPUBLIC SolarMutex {
public:
virtual void acquire() = 0;
@@ -36,6 +43,12 @@ public:
virtual bool tryToAcquire() = 0;
+ /// Help components to get the SolarMutex easily.
+ static SolarMutex *get();
+
+ /// semi-private: allow VCL to push its one-big-lock down here.
+ static void setSolarMutex( SolarMutex *pMutex );
+
protected:
SolarMutex();
diff --git a/include/tools/solarmutex.hxx b/include/tools/solarmutex.hxx
index 85e465d2ec8a..60af81c1f5a6 100644
--- a/include/tools/solarmutex.hxx
+++ b/include/tools/solarmutex.hxx
@@ -24,10 +24,10 @@
namespace tools
{
+ /// Deprecated in favour of comphelper::SolarMutex
class TOOLS_DLLPUBLIC SolarMutex
{
public:
- static void SetSolarMutex( comphelper::SolarMutex* pMutex );
static bool Acquire();
static void Release();
};
diff --git a/tools/source/misc/solarmutex.cxx b/tools/source/misc/solarmutex.cxx
index f71899901f7e..66029398a619 100644
--- a/tools/source/misc/solarmutex.cxx
+++ b/tools/source/misc/solarmutex.cxx
@@ -21,15 +21,9 @@
namespace tools
{
- static comphelper::SolarMutex* pSolarMutex = 0;
-
- void SolarMutex::SetSolarMutex( comphelper::SolarMutex* pMutex )
- {
- pSolarMutex = pMutex;
- }
-
bool SolarMutex::Acquire()
{
+ comphelper::SolarMutex *pSolarMutex = comphelper::SolarMutex::get();
if ( pSolarMutex )
pSolarMutex->acquire();
else
@@ -39,6 +33,7 @@ namespace tools
void SolarMutex::Release()
{
+ comphelper::SolarMutex *pSolarMutex = comphelper::SolarMutex::get();
if ( pSolarMutex )
pSolarMutex->release();
}
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx
index fd1c423c78d7..7d03ab82d849 100644
--- a/unotools/source/config/configitem.cxx
+++ b/unotools/source/config/configitem.cxx
@@ -40,7 +40,8 @@
#include <com/sun/star/util/XStringEscape.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
#include <osl/diagnose.h>
-#include <tools/solarmutex.hxx>
+#include <comphelper/solarmutex.hxx>
+#include <rtl/ref.hxx>
#include <rtl/ustrbuf.hxx>
using namespace utl;
@@ -155,11 +156,12 @@ void ConfigChangeListener_Impl::changesOccurred( const ChangesEvent& rEvent ) th
}
if( nNotify )
{
- if ( ::tools::SolarMutex::Acquire() )
+ ::comphelper::SolarMutex *pMutex = ::comphelper::SolarMutex::get();
+ if ( pMutex )
{
+ rtl::Reference< comphelper::SolarMutex > aGuard( pMutex );
aChangedNames.realloc(nNotify);
pParent->CallNotify(aChangedNames);
- ::tools::SolarMutex::Release();
}
}
}
diff --git a/vcl/generic/app/geninst.cxx b/vcl/generic/app/geninst.cxx
index ef7bec0ed0d9..d53ed30129a3 100644
--- a/vcl/generic/app/geninst.cxx
+++ b/vcl/generic/app/geninst.cxx
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <osl/module.hxx>
-#include <tools/solarmutex.hxx>
+#include <comphelper/solarmutex.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
#include "generic/geninst.h"
@@ -32,12 +32,12 @@ SalYieldMutex::SalYieldMutex()
{
mnCount = 0;
mnThreadId = 0;
- ::tools::SolarMutex::SetSolarMutex( this );
+ ::comphelper::SolarMutex::setSolarMutex( this );
}
SalYieldMutex::~SalYieldMutex()
{
- ::tools::SolarMutex::SetSolarMutex( NULL );
+ ::comphelper::SolarMutex::setSolarMutex( NULL );
}
void SalYieldMutex::acquire()
@@ -125,7 +125,6 @@ bool SalGenericInstance::CheckYieldMutex()
SalGenericInstance::~SalGenericInstance()
{
- ::tools::SolarMutex::SetSolarMutex( 0 );
delete mpSalYieldMutex;
}
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index bc9b2050777d..137c72f17da9 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -21,7 +21,7 @@
#include <stdio.h>
-#include <tools/solarmutex.hxx>
+#include <comphelper/solarmutex.hxx>
#include "comphelper/lok.hxx"
@@ -350,7 +350,7 @@ AquaSalInstance::AquaSalInstance()
{
mpSalYieldMutex = new SalYieldMutex;
mpSalYieldMutex->acquire();
- ::tools::SolarMutex::SetSolarMutex( mpSalYieldMutex );
+ ::comphelper::SolarMutex::setSolarMutex( mpSalYieldMutex );
maMainThread = osl::Thread::getCurrentIdentifier();
mbWaitingYield = false;
maUserEventListMutex = osl_createMutex();
@@ -360,7 +360,7 @@ AquaSalInstance::AquaSalInstance()
AquaSalInstance::~AquaSalInstance()
{
- ::tools::SolarMutex::SetSolarMutex( 0 );
+ ::comphelper::SolarMutex::setSolarMutex( 0 );
mpSalYieldMutex->release();
delete mpSalYieldMutex;
osl_destroyMutex( maUserEventListMutex );
diff --git a/vcl/win/source/app/salinst.cxx b/vcl/win/source/app/salinst.cxx
index 27af73fcaac3..4f3a28902a32 100644
--- a/vcl/win/source/app/salinst.cxx
+++ b/vcl/win/source/app/salinst.cxx
@@ -24,8 +24,6 @@
#include <osl/file.hxx>
#include <comphelper/solarmutex.hxx>
-#include <tools/solarmutex.hxx>
-
#include <vcl/apptypes.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
@@ -580,12 +578,12 @@ WinSalInstance::WinSalInstance()
mpSalWaitMutex = new osl::Mutex;
mnYieldWaitCount = 0;
mpSalYieldMutex->acquire();
- ::tools::SolarMutex::SetSolarMutex( mpSalYieldMutex );
+ ::comphelper::SolarMutex::setSolarMutex( mpSalYieldMutex );
}
WinSalInstance::~WinSalInstance()
{
- ::tools::SolarMutex::SetSolarMutex( 0 );
+ ::comphelper::SolarMutex::setSolarMutex( 0 );
mpSalYieldMutex->release();
delete mpSalYieldMutex;
delete mpSalWaitMutex;