summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2010-10-12 23:56:51 -0500
committerNorbert Thiebaud <nthiebaud@gmail.com>2010-10-25 19:55:36 -0500
commitb450a32890184a18ed176dbf717e944190cbe643 (patch)
treeddc699f571b6a544a3e78e63b23a2b8941cc16ad
parent5baa9a51a87ea15a36997cab013a1753c2fec0db (diff)
create a class SolarMutexGuard to take a Guard on the SolarMutex
Most user of OGuard, use it to guard the SolarMutex. using something like vos::OGuard aGuard(Application::GetSolarMutex()) Which will now be written vcl::SolarMutexGuard aGuard; This will also, as a side effect remove the use of vos::Guard in many sources, simplifying the migration out of ::vos
-rw-r--r--vcl/inc/vcl/svapp.hxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx
index 13b24072dbb5..5a9a27b65278 100644
--- a/vcl/inc/vcl/svapp.hxx
+++ b/vcl/inc/vcl/svapp.hxx
@@ -498,6 +498,31 @@ private:
DECL_STATIC_LINK( Application, PostEventHandler, void* );
};
+
+class VCL_DLLPUBLIC SolarMutexGuard
+{
+ private:
+ SolarMutexGuard( const SolarMutexGuard& );
+ const SolarMutexGuard& operator = ( const SolarMutexGuard& );
+ ::vos::IMutex& 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();
+ }
+};
+
/**
A helper class that calls Application::ReleaseSolarMutex() in its constructor
and restores the mutex in its destructor.