Mercurial > hg > vampy
annotate Mutex.h @ 29:e80caada79a8
* Remove nonportable and unnecessary opendir features test (originally
inherited from the Vamp SDK's implementation of a similar plugin lookup,
but it's been gone from the SDK for ages now)
* Comment out some excessive debug output
author | cannam |
---|---|
date | Tue, 22 Sep 2009 15:20:44 +0000 |
parents | 134313c59d82 |
children |
rev | line source |
---|---|
cannam@3 | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
cannam@3 | 2 |
cannam@3 | 3 /* |
cannam@3 | 4 Basic cross-platform mutex abstraction class. |
cannam@3 | 5 This file copyright 2007 Chris Cannam. |
cannam@3 | 6 */ |
cannam@3 | 7 |
cannam@3 | 8 #ifndef _MUTEX_H_ |
cannam@3 | 9 #define _MUTEX_H_ |
cannam@3 | 10 |
cannam@3 | 11 #ifdef _WIN32 |
cannam@3 | 12 #include <windows.h> |
cannam@3 | 13 #else |
cannam@3 | 14 #include <pthread.h> |
cannam@3 | 15 #endif |
cannam@3 | 16 |
cannam@3 | 17 class Mutex |
cannam@3 | 18 { |
cannam@3 | 19 public: |
cannam@3 | 20 Mutex(); |
cannam@3 | 21 ~Mutex(); |
cannam@3 | 22 |
cannam@3 | 23 void lock(); |
cannam@3 | 24 void unlock(); |
cannam@3 | 25 bool trylock(); |
cannam@3 | 26 |
cannam@3 | 27 private: |
cannam@3 | 28 #ifdef _WIN32 |
cannam@3 | 29 HANDLE m_mutex; |
cannam@3 | 30 #ifndef NO_THREAD_CHECKS |
cannam@3 | 31 DWORD m_lockedBy; |
cannam@3 | 32 #endif |
cannam@3 | 33 #else |
cannam@3 | 34 pthread_mutex_t m_mutex; |
cannam@3 | 35 #ifndef NO_THREAD_CHECKS |
cannam@3 | 36 pthread_t m_lockedBy; |
cannam@3 | 37 bool m_locked; |
cannam@3 | 38 #endif |
cannam@3 | 39 #endif |
cannam@3 | 40 }; |
cannam@3 | 41 |
cannam@3 | 42 class MutexLocker |
cannam@3 | 43 { |
cannam@3 | 44 public: |
cannam@3 | 45 MutexLocker(Mutex *); |
cannam@3 | 46 ~MutexLocker(); |
cannam@3 | 47 |
cannam@3 | 48 private: |
cannam@3 | 49 Mutex *m_mutex; |
cannam@3 | 50 }; |
cannam@3 | 51 |
cannam@3 | 52 #endif |
cannam@3 | 53 |