24 #include <core/exception.h> 25 #include <core/threading/mutex.h> 26 #include <core/threading/mutex_data.h> 27 #include <core/threading/thread.h> 61 mutex_data =
new MutexData();
63 pthread_mutexattr_t attr;
64 pthread_mutexattr_init(&attr);
66 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
68 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
71 pthread_mutex_init(&(mutex_data->mutex), &attr);
77 pthread_mutex_destroy(&(mutex_data->mutex));
90 if ((err = pthread_mutex_lock(&(mutex_data->mutex))) != 0) {
93 #ifdef DEBUG_THREADING 95 mutex_data->set_lock_holder();
119 if (pthread_mutex_trylock(&(mutex_data->mutex)) == 0) {
120 #ifdef DEBUG_THREADING 121 mutex_data->set_lock_holder();
133 #ifdef DEBUG_THREADING 134 mutex_data->unset_lock_holder();
137 pthread_mutex_unlock(&(mutex_data->mutex));
152 pthread_mutex_lock(&(mutex_data->mutex));
153 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.