summaryrefslogtreecommitdiff
path: root/include/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-08-15 08:05:51 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2017-09-19 09:25:14 +0200
commit3840aede596e6fc24f7ed7df9100fb028134aac6 (patch)
tree74d1d5efa3b2ad5448181fc185faf226aed192e4 /include/vcl
parent10b49dfb3996f99dec8dd0d2ffae2aef4022f395 (diff)
Unify SolarMutex implementations
All backends implement the SolarMutex in mostly the same way. So this consolidates this code into a GenericSolarMutex. We still need the abstract SolarMutex class for the fake AKA fascade implementation in dbaccess. The patch also replaces various places of direct mutex usage with either SolarMutexGuard or SolarMutexReleaser objects. Change-Id: Ia0146dd6c51a3b9a513cc6af34a66def58aad831 Reviewed-on: https://gerrit.libreoffice.org/42325 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'include/vcl')
-rw-r--r--include/vcl/svapp.hxx114
1 files changed, 14 insertions, 100 deletions
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index 7bdb4daccfb6..1d016044335e 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -28,6 +28,7 @@
#include <vector>
#include <comphelper/solarmutex.hxx>
+#include <osl/mutex.hxx>
#include <rtl/ustring.hxx>
#include <osl/thread.hxx>
#include <tools/gen.hxx>
@@ -531,7 +532,7 @@ public:
@see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
GetMainThreadIdentifier, AcquireSolarMutex,
*/
- static sal_uLong ReleaseSolarMutex();
+ static sal_uInt32 ReleaseSolarMutex();
/** @brief Acquire Solar Mutex(es) for this thread.
@@ -541,7 +542,7 @@ public:
@see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
GetMainThreadIdentifier, ReleaseSolarMutex,
*/
- static void AcquireSolarMutex( sal_uLong nCount );
+ static void AcquireSolarMutex( sal_uInt32 nCount );
/** Queries whether the application is in "main", i.e. not yet in
the event loop
@@ -1397,110 +1398,28 @@ private:
DECL_STATIC_LINK( Application, PostEventHandler, void*, void );
};
-
class VCL_DLLPUBLIC SolarMutexGuard
+ : public osl::Guard<comphelper::SolarMutex>
{
-private:
- SolarMutexGuard( const SolarMutexGuard& ) = delete;
- const SolarMutexGuard& operator = ( const SolarMutexGuard& ) = delete;
- comphelper::SolarMutex& m_solarMutex;
-
public:
- /** Acquires the object specified as parameter.
- */
- SolarMutexGuard() :
- m_solarMutex(Application::GetSolarMutex())
- {
- m_solarMutex.acquire();
- }
-
- /** Releases the mutex or interface. */
- ~SolarMutexGuard()
- {
- m_solarMutex.release();
- }
+ SolarMutexGuard()
+ : osl::Guard<comphelper::SolarMutex>( Application::GetSolarMutex() ) {}
};
-class VCL_DLLPUBLIC SolarMutexClearableGuard final
+class VCL_DLLPUBLIC SolarMutexClearableGuard
+ : public osl::ClearableGuard<comphelper::SolarMutex>
{
- SolarMutexClearableGuard( const SolarMutexClearableGuard& ) = delete;
- const SolarMutexClearableGuard& operator = ( const SolarMutexClearableGuard& ) = delete;
- bool m_bCleared;
- comphelper::SolarMutex& m_solarMutex;
public:
- /** Acquires mutex
- */
SolarMutexClearableGuard()
- : m_bCleared(false)
- , m_solarMutex( Application::GetSolarMutex() )
- {
- m_solarMutex.acquire();
- }
-
- /** Releases mutex. */
- ~SolarMutexClearableGuard()
- {
- if( !m_bCleared )
- {
- m_solarMutex.release();
- }
- }
-
- /** Releases mutex. */
- void SAL_CALL clear()
- {
- if( !m_bCleared )
- {
- m_solarMutex.release();
- m_bCleared = true;
- }
- }
+ : osl::ClearableGuard<comphelper::SolarMutex>( Application::GetSolarMutex() ) {}
};
-class VCL_DLLPUBLIC SolarMutexResettableGuard final
+class VCL_DLLPUBLIC SolarMutexResettableGuard
+ : public osl::ResettableGuard<comphelper::SolarMutex>
{
- SolarMutexResettableGuard( const SolarMutexResettableGuard& ) = delete;
- const SolarMutexResettableGuard& operator = ( const SolarMutexResettableGuard& ) = delete;
- bool m_bCleared;
- comphelper::SolarMutex& m_solarMutex;
public:
- /** Acquires mutex
- */
SolarMutexResettableGuard()
- : m_bCleared(false)
- , m_solarMutex( Application::GetSolarMutex() )
- {
- m_solarMutex.acquire();
- }
-
- /** Releases mutex. */
- ~SolarMutexResettableGuard()
- {
- if( !m_bCleared )
- {
- m_solarMutex.release();
- }
- }
-
- /** Releases mutex. */
- void SAL_CALL clear()
- {
- if( !m_bCleared)
- {
- m_solarMutex.release();
- m_bCleared = true;
- }
- }
-
- /** Re-acquires mutex. */
- void SAL_CALL reset()
- {
- if( m_bCleared)
- {
- m_solarMutex.acquire();
- m_bCleared = false;
- }
- }
+ : osl::ResettableGuard<comphelper::SolarMutex>( Application::GetSolarMutex() ) {}
};
namespace vcl
@@ -1559,15 +1478,10 @@ public:
*/
class SolarMutexReleaser
{
- sal_uLong mnReleased;
-
+ const sal_uInt32 mnReleased;
public:
SolarMutexReleaser(): mnReleased(Application::ReleaseSolarMutex()) {}
-
- ~SolarMutexReleaser()
- {
- Application::ReAcquireSolarMutex(mnReleased);
- }
+ ~SolarMutexReleaser() { Application::ReAcquireSolarMutex(mnReleased); }
};
VCL_DLLPUBLIC Application* GetpApp();