Mercurial > hg > orthanc
changeset 2108:68510b1c2433
Semaphore::Locker
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 22 Oct 2016 18:22:18 +0200 |
parents | 88831c3edd8f |
children | d5c29fd74ffa |
files | Core/MultiThreading/Semaphore.h |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
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(); + } + }; }; }