summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-06-20 11:13:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-06-21 08:19:49 +0200
commit4c93de2c921b43193985c057b03e329d6dddc5d4 (patch)
tree3deccb18a9ebc941f7dcd3ff14780b8dcd9951f2 /include
parentec665e3e898e733c9f602b21046079e569b58568 (diff)
merge GenericSolarMutex and SolarMutex
Since nothing else is implementing the SolarMutex abstract class. Change-Id: I2a41254af3e9c7534033cdd0bece9dd8e0258b9d Reviewed-on: https://gerrit.libreoffice.org/56153 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r--include/comphelper/solarmutex.hxx63
1 files changed, 18 insertions, 45 deletions
diff --git a/include/comphelper/solarmutex.hxx b/include/comphelper/solarmutex.hxx
index e00f51dd728a..890b3e3762dd 100644
--- a/include/comphelper/solarmutex.hxx
+++ b/include/comphelper/solarmutex.hxx
@@ -30,23 +30,30 @@ namespace comphelper {
/**
- * Abstract SolarMutex interface, needed for VCL's
- * Application::GetSolarMutex().
+ * SolarMutex, 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.
+ *
+ * Treat this as a singleton, as its constructor sets a global
+ * pointing at itself.
*/
class COMPHELPER_DLLPUBLIC SolarMutex {
public:
+ typedef void (*BeforeReleaseHandler) ();
+
+ void SetBeforeReleaseHandler( const BeforeReleaseHandler& rLink )
+ { m_aBeforeReleaseHandler = rLink; }
+
void acquire( sal_uInt32 nLockCount = 1 );
sal_uInt32 release( bool bUnlockAll = false );
- virtual bool tryToAcquire() = 0;
+ virtual bool tryToAcquire();
// returns true, if the mutex is owned by the current thread
- virtual bool IsCurrentThread() const = 0;
+ virtual bool IsCurrentThread() const;
/// Help components to get the SolarMutex easily.
static SolarMutex *get();
@@ -55,15 +62,18 @@ protected:
SolarMutex();
virtual ~SolarMutex();
- /// allow VCL to push its one-big-lock down here.
- static void setSolarMutex( SolarMutex *pMutex );
+ virtual sal_uInt32 doRelease( bool bUnlockAll );
+ virtual void doAcquire( sal_uInt32 nLockCount );
- virtual sal_uInt32 doRelease( bool bUnlockAll ) = 0;
- virtual void doAcquire( sal_uInt32 nLockCount ) = 0;
+ osl::Mutex m_aMutex;
+ sal_uInt32 m_nCount;
+ oslThreadIdentifier m_nThreadId;
private:
SolarMutex(const SolarMutex&) = delete;
SolarMutex& operator=(const SolarMutex&) = delete;
+
+ BeforeReleaseHandler m_aBeforeReleaseHandler;
};
inline void SolarMutex::acquire( sal_uInt32 nLockCount )
@@ -77,43 +87,6 @@ inline sal_uInt32 SolarMutex::release( bool bUnlockAll )
return doRelease( bUnlockAll );
}
-
-/**
- * Generic implementation of the abstract SolarMutex interface.
- *
- * Treat this as a singleton, as its constructor calls
- * setSolarMutex( this )!
- *
- * Kept separated from SolarMutex, so others can implement facades.
- */
-class COMPHELPER_DLLPUBLIC GenericSolarMutex
- : public SolarMutex
-{
-public:
- typedef void (*BeforeReleaseHandler) ();
-
- void SetBeforeReleaseHandler( const BeforeReleaseHandler& rLink )
- { m_aBeforeReleaseHandler = rLink; }
-
- virtual bool tryToAcquire() override;
- virtual bool IsCurrentThread() const override;
-
-protected:
- osl::Mutex m_aMutex;
- sal_uInt32 m_nCount;
- oslThreadIdentifier m_nThreadId;
-
- virtual void doAcquire( sal_uInt32 nLockCount ) override;
- virtual sal_uInt32 doRelease( bool bUnlockAll ) override;
-
-protected:
- GenericSolarMutex();
- virtual ~GenericSolarMutex() override;
-
-private:
- BeforeReleaseHandler m_aBeforeReleaseHandler;
-};
-
}
#endif // INCLUDED_COMPHELPER_SOLARMUTEX_HXX