From 80729c8f066983d50883140620a5b2833fda61c0 Mon Sep 17 00:00:00 2001 From: Norbert Thiebaud Date: Sat, 12 Mar 2011 18:54:40 -0600 Subject: add a SolarMutexResettableGuard... needed in sfx2 --- vcl/inc/vcl/svapp.hxx | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'vcl/inc/vcl/svapp.hxx') diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx index 7f9fc9ecd928..85e902161a48 100644 --- a/vcl/inc/vcl/svapp.hxx +++ b/vcl/inc/vcl/svapp.hxx @@ -557,6 +557,52 @@ protected: osl::SolarMutex& m_solarMutex; }; +class VCL_DLLPUBLIC SolarMutexResettableGuard +{ + SolarMutexResettableGuard( const SolarMutexResettableGuard& ); + const SolarMutexResettableGuard& operator = ( const SolarMutexResettableGuard& ); + bool m_bCleared; +public: + /** Acquires mutex + @param pMutex pointer to mutex which is to be acquired */ + SolarMutexResettableGuard() + : m_bCleared(false) + , m_solarMutex( Application::GetSolarMutex() ) + { + m_solarMutex.acquire(); + } + + /** Releases mutex. */ + virtual ~SolarMutexResettableGuard() + { + if( !m_bCleared ) + { + m_solarMutex.release(); + } + } + + /** Releases mutex. */ + void SAL_CALL clear() + { + if( !m_bCleared) + { + m_solarMutex.release(); + m_bCleared = true; + } + } + /** Releases mutex. */ + void SAL_CALL reset() + { + if( m_bCleared) + { + m_solarMutex.acquire(); + m_bCleared = false; + } + } +protected: + osl::SolarMutex& m_solarMutex; +}; + /** A helper class that calls Application::ReleaseSolarMutex() in its constructor -- cgit v1.2.3