blob: d561f1a6427cb769f995adbf72990abcb6e05270 (
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
36
37
38
39
40
41
42
43
44
45
 | #ifndef HEADER_MUTEX_H
#define HEADER_MUTEX_H
#include "Base.h"
#include <memory>
#ifdef CRU_WINDOWS
#include <Windows.h>
#else
#include <pthread.h>
#endif
namespace cru {
class CRU_API Mutex {
public:
  Mutex();
  Mutex(const Mutex &other) = delete;
  Mutex &operator=(const Mutex &other) = delete;
  Mutex(Mutex &&other);
  Mutex &operator=(Mutex &&other);
  ~Mutex();
public:
  void Lock();
  bool TryLock();
  void Unlock();
private:
  void Destroy();
private:
#ifdef CRU_WINDOWS
  HANDLE handle_;
#else
  std::unique_ptr<pthread_mutex_t> mutex_;
#endif
};
} // namespace cru
#endif
 |