this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Adding missing rwmutex.h

+73
+73
src/util/rwmutex.h
··· 1 + #ifndef RWLOCK_H 2 + #define RWLOCK_H 3 + #include <pthread.h> 4 + 5 + namespace Darling { 6 + 7 + class RWMutex 8 + { 9 + public: 10 + RWMutex() 11 + { 12 + pthread_rwlock_init(&m_lock, nullptr); 13 + } 14 + ~RWMutex() 15 + { 16 + pthread_rwlock_destroy(&m_lock); 17 + } 18 + 19 + void rdlock() 20 + { 21 + pthread_rwlock_rdlock(&m_lock); 22 + } 23 + 24 + void wrlock() 25 + { 26 + pthread_rwlock_wrlock(&m_lock); 27 + } 28 + 29 + void unlock() 30 + { 31 + pthread_rwlock_unlock(&m_lock); 32 + } 33 + private: 34 + pthread_rwlock_t m_lock; 35 + }; 36 + 37 + class RWMutexReadLock 38 + { 39 + public: 40 + RWMutexReadLock(RWMutex& mut) 41 + : m_mutex(mut) 42 + { 43 + m_mutex.rdlock(); 44 + } 45 + 46 + ~RWMutexReadLock() 47 + { 48 + m_mutex.unlock(); 49 + } 50 + private: 51 + RWMutex& m_mutex; 52 + }; 53 + 54 + class RWMutexWriteLock 55 + { 56 + public: 57 + RWMutexWriteLock(RWMutex& mut) 58 + : m_mutex(mut) 59 + { 60 + m_mutex.wrlock(); 61 + } 62 + 63 + ~RWMutexWriteLock() 64 + { 65 + m_mutex.unlock(); 66 + } 67 + private: 68 + RWMutex& m_mutex; 69 + }; 70 + 71 + } 72 + 73 + #endif