diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-03-12 18:54:40 -0600 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-03-12 19:02:03 -0600 |
commit | 80729c8f066983d50883140620a5b2833fda61c0 (patch) | |
tree | 194b3770ac6a037aa380d45b2cace6ae69eb7d04 /vcl/inc | |
parent | 33186f9a81002ee6fa20e783ddd25123a58a78bf (diff) |
add a SolarMutexResettableGuard... needed in sfx2
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/vcl/svapp.hxx | 46 |
1 files changed, 46 insertions, 0 deletions
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 |