# HG changeset patch # User Sebastien Jodogne # Date 1477153338 -7200 # Node ID 68510b1c2433956cd3e10caeae5d689de2ebfc30 # Parent 88831c3edd8fc444b3d490e5f94142d1d2c94cbf Semaphore::Locker diff -r 88831c3edd8f -r 68510b1c2433 Core/MultiThreading/Semaphore.h --- 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(); + } + }; }; }