SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimpleMutex.h
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
19
20
21
22 #ifndef __SIMPLE_MUTEX_H
23 #define __SIMPLE_MUTEX_H
24
25 #include "memoryoverride.h"
26
27
28 #if defined(_WIN32)
29 #include "WindowsIncludes.h"
30
31
32 #else
33 #include <pthread.h>
34 #include <sys/types.h>
35 #endif
36 #include "Export.h"
37
38 namespace SLNet
39 {
40
45 class RAK_DLL_EXPORT SimpleMutex
46 {
47 public:
48
49 // Constructor
50 SimpleMutex();
51
52 // Destructor
53 ~SimpleMutex();
54
55 // Locks the mutex. Slow!
56 void Lock(void);
57
58 // Unlocks the mutex.
59 void Unlock(void);
60
61
62
63
64
65
66
67 private:
68 void Init(void);
69 #ifdef _WIN32
70 CRITICAL_SECTION criticalSection;
71
72
73 #else
74 pthread_mutex_t hMutex;
75 #endif
76 // Not threadsafe
77 // bool isInitialized;
78 };
79
80 } // namespace SLNet
81
82 #endif
83