MrSID Decode SDK for LiDAR Reference Manual 1.1.5.5244
Mutex.h
Go to the documentation of this file.
1//
2// This code is property of Celartem, Inc dba Extensis.
3// Copyright (c) 1995-2023. All rights reserved.
4// Use permitted only under license from Extensis.
5//
6/* PUBLIC */
7
8#ifndef __LIDAR_MUTEX_H__
9#define __LIDAR_MUTEX_H__
10
11#include "lidar/Base.h"
12
13#ifdef _WIN32
14#define NOMINMAX
15#include <windows.h>
16#else
17#include <pthread.h>
18#endif
19
20LT_BEGIN_LIDAR_NAMESPACE
21
25class Mutex
26{
27 SIMPLE_OBJECT(Mutex);
28public:
30 Mutex(void);
32 ~Mutex(void);
33
35 void lock(void);
37 void unlock(void);
38private:
39#ifdef _WIN32
40 HANDLE m_mutex;
41#else
42 pthread_mutex_t m_mutex;
43#endif
44};
45
46
52{
53 DISABLE_COPY(MutexMonitor);
54public:
57 m_mutex(mutex)
58 {
59 m_mutex.lock();
60 }
61
64 {
65 m_mutex.unlock();
66 }
67private:
68 Mutex &m_mutex;
69};
70
71LT_END_LIDAR_NAMESPACE
72#endif // __LIDAR_MUTEX_H__
Mutex is a cross platform wrapper for mutexes.
Definition: Mutex.h:26
Mutex(void)
Create unnamed mutex.
~Mutex(void)
Destroy mutex.
void unlock(void)
Unlock the mutex.
void lock(void)
Lock the mutex and block until it becomes available.
MutexMonitor use Resource Acquisition Is Initialization (RAII) to mutex lock blocks of code.
Definition: Mutex.h:52
~MutexMonitor(void)
Unlock the mutex.
Definition: Mutex.h:63
MutexMonitor(Mutex &mutex)
Lock the mutex.
Definition: Mutex.h:56

Extensis