From 4f05cb2af239ca8471b77c9f1d1c32e8c4cd3abc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Mar 2013 21:48:28 +0100 Subject: Remove .bat files, actually finish rename this time --- faceapi/mutex.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 faceapi/mutex.h (limited to 'faceapi/mutex.h') diff --git a/faceapi/mutex.h b/faceapi/mutex.h new file mode 100644 index 00000000..11aabafc --- /dev/null +++ b/faceapi/mutex.h @@ -0,0 +1,44 @@ +#ifndef SM_API_TESTAPPCONSOLE_MUTEX_H +#define SM_API_TESTAPPCONSOLE_MUTEX_H + +namespace sm +{ + namespace faceapi + { + namespace samplecode + { + // A very simple mutex class for sample code purposes. + // It is recommended that you use the boost threads library. + class Mutex + { + public: + Mutex() + { + if (!InitializeCriticalSectionAndSpinCount(&_cs,0x80000400)) + { + throw std::runtime_error("Failed to initialize Mutex"); + } + } + ~Mutex() + { + DeleteCriticalSection(&_cs); + } + void lock() const + { + EnterCriticalSection(&_cs); + } + void unlock() const + { + LeaveCriticalSection(&_cs); + } + private: + // Noncopyable + Mutex(const Mutex &); + Mutex &operator=(const Mutex &); + private: + mutable CRITICAL_SECTION _cs; + }; + } + } +} +#endif -- cgit v1.2.3