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));
Base class for exceptions in Fawkes.
bool try_lock()
Tries to lock the mutex.
@ RECURSIVE
A thread attempting to relock this mutex without first unlocking it shall succeed in locking the mute...
void lock()
Lock this mutex.
void stopby()
Shortly stop by at the mutex.
void unlock()
Unlock the mutex.
Mutex(Type type=NORMAL)
Constructor.
static Thread * current_thread()
Get the Thread instance of the currently running thread.
Fawkes library namespace.