MrSID Decode SDK for LiDAR Reference Manual 1.1.4.4709

- Main Page
- Classes
- Files

- File List
- File Members

Mutex.h
Go to the documentation of this file.
1 /* //////////////////////////////////////////////////////////////////////////
2 // //
3 // This code is Copyright (c) 2008-2010 LizardTech, Inc, 1008 Western //
4 // Avenue, Suite 200, Seattle, WA 98104. Unauthorized use or distribution //
5 // prohibited. Access to and use of this code is permitted only under //
6 // license from LizardTech, Inc. Portions of the code are protected by //
7 // US and foreign patents and other filings. All Rights Reserved. //
8 // //
10 /* PUBLIC */
11
12 #ifndef __LIDAR_MUTEX_H__
13 #define __LIDAR_MUTEX_H__
14
15 #include "lidar/Base.h"
16
17 #ifdef _WIN32
18 #define NOMINMAX
19 #include <windows.h>
20 #else
21 #include <pthread.h>
22 #endif
23
24 LT_BEGIN_LIDAR_NAMESPACE
25
29 class Mutex
30 {
31 SIMPLE_OBJECT(Mutex);
32 public:
34 Mutex(void);
36 ~Mutex(void);
37
39 void lock(void);
41 void unlock(void);
42 private:
43 #ifdef _WIN32
44 HANDLE m_mutex;
45 #else
46 pthread_mutex_t m_mutex;
47 #endif
48 };
49
50
55 class MutexMonitor
56 {
57 DISABLE_COPY(MutexMonitor);
58 public:
60 MutexMonitor(Mutex &mutex) :
61 m_mutex(mutex)
62 {
63 m_mutex.lock();
64 }
65
67 ~MutexMonitor(void)
68 {
69 m_mutex.unlock();
70 }
71 private:
72 Mutex &m_mutex;
73 };
74
75 LT_END_LIDAR_NAMESPACE
76 #endif // __LIDAR_MUTEX_H__

LizardTech