summaryrefslogtreecommitdiffhomepage
path: root/faceapi/lock.h
diff options
context:
space:
mode:
Diffstat (limited to 'faceapi/lock.h')
-rw-r--r--faceapi/lock.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/faceapi/lock.h b/faceapi/lock.h
new file mode 100644
index 00000000..efe38605
--- /dev/null
+++ b/faceapi/lock.h
@@ -0,0 +1,35 @@
+#ifndef SM_API_TESTAPPCONSOLE_LOCK_H
+#define SM_API_TESTAPPCONSOLE_LOCK_H
+
+#include "mutex.h"
+
+namespace sm
+{
+ namespace faceapi
+ {
+ namespace samplecode
+ {
+ // A very simple scoped-lock class for sample code purposes.
+ // It is recommended that you use the boost threads library.
+ class Lock
+ {
+ public:
+ Lock(const Mutex &mutex): _mutex(mutex)
+ {
+ _mutex.lock();
+ }
+ ~Lock()
+ {
+ _mutex.unlock();
+ }
+ private:
+ // Noncopyable
+ Lock(const Lock &);
+ Lock &operator=(const Lock &);
+ private:
+ const Mutex &_mutex;
+ };
+ }
+ }
+}
+#endif