From 6df767863656d2e3efffed562a02180b3ea11624 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 25 Aug 2011 06:48:24 +0000 Subject: Bu::ItoLocker is rather handy, I like it. I reccomend it. --- src/itolocker.cpp | 13 +++++++++++++ src/itolocker.h | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/itolocker.cpp create mode 100644 src/itolocker.h (limited to 'src') diff --git a/src/itolocker.cpp b/src/itolocker.cpp new file mode 100644 index 0000000..17e97fd --- /dev/null +++ b/src/itolocker.cpp @@ -0,0 +1,13 @@ +#include "bu/itolocker.h" +#include "bu/itomutex.h" + +Bu::ItoLocker::ItoLocker( Bu::ItoMutex &mu ) : + mu( mu ) +{ + mu.lock(); +} + +Bu::ItoLocker::~ItoLocker() +{ + mu.unlock(); +} diff --git a/src/itolocker.h b/src/itolocker.h new file mode 100644 index 0000000..76e5198 --- /dev/null +++ b/src/itolocker.h @@ -0,0 +1,18 @@ +#ifndef BU_ITO_LOCKER_H +#define BU_ITO_LOCKER_H + +namespace Bu +{ + class ItoMutex; + class ItoLocker + { + public: + ItoLocker( ItoMutex &mu ); + virtual ~ItoLocker(); + + private: + ItoMutex & mu; + }; +}; + +#endif -- cgit v1.2.3