24 #include <core/threading/mutex.h> 25 #include <core/threading/mutex_data.h> 26 #include <core/threading/thread.h> 27 #include <core/exception.h> 62 mutex_data =
new MutexData();
64 pthread_mutexattr_t attr;
65 pthread_mutexattr_init(&attr);
67 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
69 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
72 pthread_mutex_init(&(mutex_data->mutex), &attr);
78 pthread_mutex_destroy(&(mutex_data->mutex));
92 if ( (err = pthread_mutex_lock(&(mutex_data->mutex))) != 0 ) {
95 #ifdef DEBUG_THREADING 97 mutex_data->set_lock_holder();
122 if (pthread_mutex_trylock(&(mutex_data->mutex)) == 0) {
123 #ifdef DEBUG_THREADING 124 mutex_data->set_lock_holder();
137 #ifdef DEBUG_THREADING 138 mutex_data->unset_lock_holder();
141 pthread_mutex_unlock(&(mutex_data->mutex));
157 pthread_mutex_lock(&(mutex_data->mutex));
158 pthread_mutex_unlock(&(mutex_data->mutex));
Fawkes library namespace.
void unlock()
Unlock the mutex.
Base class for exceptions in Fawkes.
A thread attempting to relock this mutex without first unlocking it shall succeed in locking the mute...
static Thread * current_thread()
Get the Thread instance of the currently running thread.
bool try_lock()
Tries to lock the mutex.
void lock()
Lock this mutex.
Mutex(Type type=NORMAL)
Constructor.
void stopby()
Shortly stop by at the mutex.