Mercurial > hg > vampy
comparison Mutex.h @ 37:27bab3a16c9a vampy2final
new branch Vampy2final
author | fazekasgy |
---|---|
date | Mon, 05 Oct 2009 11:28:00 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 37:27bab3a16c9a |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Basic cross-platform mutex abstraction class. | |
5 This file copyright 2007 Chris Cannam. | |
6 */ | |
7 | |
8 #ifndef _MUTEX_H_ | |
9 #define _MUTEX_H_ | |
10 | |
11 #ifdef _WIN32 | |
12 #include <windows.h> | |
13 #else | |
14 #include <pthread.h> | |
15 #endif | |
16 | |
17 class Mutex | |
18 { | |
19 public: | |
20 Mutex(); | |
21 ~Mutex(); | |
22 | |
23 void lock(); | |
24 void unlock(); | |
25 bool trylock(); | |
26 | |
27 private: | |
28 #ifdef _WIN32 | |
29 HANDLE m_mutex; | |
30 #ifndef NO_THREAD_CHECKS | |
31 DWORD m_lockedBy; | |
32 #endif | |
33 #else | |
34 pthread_mutex_t m_mutex; | |
35 #ifndef NO_THREAD_CHECKS | |
36 pthread_t m_lockedBy; | |
37 bool m_locked; | |
38 #endif | |
39 #endif | |
40 }; | |
41 | |
42 class MutexLocker | |
43 { | |
44 public: | |
45 MutexLocker(Mutex *); | |
46 ~MutexLocker(); | |
47 | |
48 private: | |
49 Mutex *m_mutex; | |
50 }; | |
51 | |
52 #endif | |
53 |