Kaydet (Commit) f76b3dd0 authored tarafından Michael Meeks's avatar Michael Meeks

Move SolarMutex down from tools to comphelper/ to make life easier.

Change-Id: I7dd21f30daa27e5de2848eb16aee9a610dd629d5
Reviewed-on: https://gerrit.libreoffice.org/19271Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 3e23ee07
......@@ -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: */
......@@ -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();
......
......@@ -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();
};
......
......@@ -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();
}
......
......@@ -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();
}
}
}
......
......@@ -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;
}
......
......@@ -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 );
......
......@@ -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;
......
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