summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/Mutex.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/sys/Mutex.h')
-rw-r--r--cpp/src/qpid/sys/Mutex.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/cpp/src/qpid/sys/Mutex.h b/cpp/src/qpid/sys/Mutex.h
index b8545d4449..b4bd3a9b4a 100644
--- a/cpp/src/qpid/sys/Mutex.h
+++ b/cpp/src/qpid/sys/Mutex.h
@@ -66,6 +66,18 @@ class ScopedWlock
L& mutex;
};
+template <class L>
+class ConditionalScopedLock
+{
+ public:
+ ConditionalScopedLock(L& l) : mutex(l) { acquired = l.trylock(); }
+ ~ConditionalScopedLock() { if (acquired) mutex.unlock(); }
+ bool lockAcquired() { return acquired; }
+ private:
+ L& mutex;
+ bool acquired;
+};
+
}}
#ifdef USE_APR_PLATFORM