summaryrefslogtreecommitdiffhomepage
path: root/faceapi/xxx_lock.h
blob: efe38605fb67902895d002c415490979b179fc81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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