summaryrefslogtreecommitdiffhomepage
path: root/faceAPI/mutex.h
diff options
context:
space:
mode:
authorWim Vriend <facetracknoir@gmail.com>2011-03-21 21:32:13 +0000
committerWim Vriend <facetracknoir@gmail.com>2011-03-21 21:32:13 +0000
commit7eeb8dfaede7bb54b37b8ea538135914a43ab011 (patch)
tree890f04508697583a3d3e1b849181122278096701 /faceAPI/mutex.h
parent09b4c95b8036b9466ca89acbe0b1f3d810499863 (diff)
New effort to embrace faceAPI 3.2.6
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@54 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'faceAPI/mutex.h')
-rw-r--r--faceAPI/mutex.h44
1 files changed, 44 insertions, 0 deletions
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