13 template <
typename Mutex>
95 CRITICAL_SECTION _mutex;
97 pthread_mutex_t _mutex;
104 InitializeCriticalSection(&_mutex);
106 pthread_mutexattr_t attr;
107 pthread_mutexattr_init(&attr);
108 pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
109 pthread_mutex_init(&_mutex,&attr);
110 pthread_mutexattr_destroy(&attr);
132 if(in_mutex._locked && !_locked) lock();
133 else if(!in_mutex._locked && _locked) unlock();
142 if(in_mutex._locked && !_locked) lock();
143 else if(!in_mutex._locked && _locked) unlock();
152 DeleteCriticalSection(&_mutex);
154 pthread_mutex_unlock(&_mutex);
155 pthread_mutex_destroy(&_mutex);
167 EnterCriticalSection(&_mutex);
170 return pthread_mutex_lock(&_mutex) == 0;
181 return !!TryEnterCriticalSection(&_mutex);
183 return pthread_mutex_trylock(&_mutex) == 0;
195 LeaveCriticalSection(&_mutex);
198 return pthread_mutex_unlock(&_mutex) == 0;
bool lock()
lock a mutex
Definition: Mutex.hpp:164
virtual ~Mutex()
Destructor.
Definition: Mutex.hpp:150
Mutex & operator=(const Mutex &in_mutex)
Copy a mutex (copy the locked state only)
Definition: Mutex.hpp:141
different physics engine has different winding order.
Definition: EventBinding.h:32
bool unlock()
unlock a mutex
Definition: Mutex.hpp:192
Mutex(const Mutex &in_mutex)
Copy Constructor a mutex (copy the locked state only)
Definition: Mutex.hpp:129
simple scoped lock function
Definition: Mutex.hpp:14
Mutex()
Construct a Mutex.
Definition: Mutex.hpp:121
cross platform mutex
Definition: Mutex.hpp:88
bool tryLock()
lock a mutex
Definition: Mutex.hpp:178
bool isLocked() const
Fast locked look up.
Definition: Mutex.hpp:215
cross platform mutex
Definition: mutex.h:95