copying condition-class branch over from my 2012 repo
diff --git a/aos/common/mutex.h b/aos/common/mutex.h
index 035889b..4c06aae 100644
--- a/aos/common/mutex.h
+++ b/aos/common/mutex.h
@@ -64,6 +64,20 @@
Mutex *mutex_;
DISALLOW_COPY_AND_ASSIGN(MutexLocker);
};
+// The inverse of MutexLocker.
+class MutexUnlocker {
+ public:
+ explicit MutexUnlocker(Mutex *mutex) : mutex_(mutex) {
+ mutex_->Unlock();
+ }
+ ~MutexUnlocker() {
+ mutex_->Lock();
+ }
+
+ private:
+ Mutex *mutex_;
+ DISALLOW_COPY_AND_ASSIGN(MutexUnlocker);
+};
} // namespace aos