diff Core/MultiThreading/Semaphore.h @ 2108:68510b1c2433

Semaphore::Locker
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 22 Oct 2016 18:22:18 +0200
parents b1291df2f780
children 29689b30f9ae
line wrap: on
line diff
--- a/Core/MultiThreading/Semaphore.h	Wed Oct 19 17:22:09 2016 +0200
+++ b/Core/MultiThreading/Semaphore.h	Sat Oct 22 18:22:18 2016 +0200
@@ -50,5 +50,23 @@
     void Release();
 
     void Acquire();
+
+    class Locker : public boost::noncopyable
+    {
+    private:
+      Semaphore&  that_;
+
+    public:
+      Locker(Semaphore& that) :
+        that_(that)
+      {
+        that_.Acquire();
+      }
+
+      ~Locker()
+      {
+        that_.Release();
+      }
+    };
   };
 }