3 #include <boost/noncopyable.hpp> 4 #include <boost/thread/mutex.hpp> 11 template <
typename Mutex>
71 template <
typename Mutex>
75 bool locked()
const {
return true; };
102 CRITICAL_SECTION _mutex;
104 pthread_mutex_t _mutex;
111 InitializeCriticalSection(&_mutex);
113 pthread_mutexattr_t attr;
114 pthread_mutexattr_init(&attr);
115 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
116 pthread_mutex_init(&_mutex, &attr);
117 pthread_mutexattr_destroy(&attr);
139 if (in_mutex._locked && !_locked) lock();
140 else if (!in_mutex._locked && _locked) unlock();
149 if (in_mutex._locked && !_locked) lock();
150 else if (!in_mutex._locked && _locked) unlock();
159 DeleteCriticalSection(&_mutex);
161 pthread_mutex_unlock(&_mutex);
162 pthread_mutex_destroy(&_mutex);
174 EnterCriticalSection(&_mutex);
177 return pthread_mutex_lock(&_mutex) == 0;
188 return !!TryEnterCriticalSection(&_mutex);
190 return pthread_mutex_trylock(&_mutex) == 0;
202 LeaveCriticalSection(&_mutex);
205 return pthread_mutex_unlock(&_mutex) == 0;
bool lock()
lock a mutex
Definition: Mutex.hpp:164
mutex()
Construct a mutex.
Definition: mutex.h:128
bool unlock()
unlock a mutex
Definition: mutex.h:199
bool lock()
lock a mutex
Definition: mutex.h:171
different physics engine has different winding order.
Definition: EventBinding.h:32
simple scoped lock function
Definition: mutex.h:12
bool unlock()
unlock a mutex
Definition: Mutex.hpp:192
bool tryLock()
lock a mutex
Definition: mutex.h:185
mutex(const mutex &in_mutex)
Copy Constructor a mutex (copy the locked state only)
Definition: mutex.h:136
mutex & operator=(const mutex &in_mutex)
Copy a mutex (copy the locked state only)
Definition: mutex.h:148
cross platform mutex
Definition: Mutex.hpp:88
a dummy lock object with all dummy interface functions
Definition: mutex.h:72
cross platform mutex
Definition: mutex.h:95
virtual ~mutex()
Destructor.
Definition: mutex.h:157
bool isLocked() const
Fast locked look up.
Definition: mutex.h:222