8 unsigned& ref_debug_lock_counter()
10 static unsigned counter = 0;
14 mutex& ref_debug_mutex()
23 return ref_debug_lock_counter();
29 pthread_mutex_init (&(pthread_mutex_t&)pmutex, NULL);
35 pthread_mutex_destroy (&(pthread_mutex_t&)pmutex);
42 pthread_mutex_lock (&(pthread_mutex_t&)pmutex);
48 pthread_mutex_unlock (&(pthread_mutex_t&)pmutex);
54 ref_debug_mutex().
lock();
56 ++ref_debug_lock_counter();
57 ref_debug_mutex().
unlock();
59 ref_debug_mutex().
lock();
60 std::cout << info <<
": received lock [" <<
this <<
"]" << std::endl;
61 ref_debug_mutex().
unlock();
67 ref_debug_mutex().
lock();
68 std::cout << info <<
": unlock [" <<
this <<
"]" << std::endl;
69 ref_debug_mutex().
unlock();
76 return pthread_mutex_trylock(&(pthread_mutex_t&)pmutex) != EBUSY;
82 pthread_cond_init(&(pthread_cond_t&)pcond, NULL);
88 pthread_cond_destroy(&(pthread_cond_t&)pcond);
94 pthread_cond_signal(&(pthread_cond_t&)pcond);
108 pthread_cond_broadcast(&(pthread_cond_t&)pcond);
~mutex()
destruct a mutex
Definition: mutex_pthread.h:33
void send_signal()
send the signal to unblock a thread waiting for the condition represented by this condition_mutex
Definition: mutex_pthread.h:92
void broadcast_signal_with_lock()
prefered approach to broadcast the signal and implemented as {lock();broadcast_signal();unlock();}
Definition: mutex_pthread.h:112
void unlock()
unlock the mutex
Definition: mutex_pthread.h:46
mutex()
construct a mutex
Definition: mutex_pthread.h:27
void debug_lock(const std::string &info)
same as lock but with printing debug information
Definition: mutex_pthread.h:52
void lock()
lock the mutex (if the mutex is already locked, the caller is blocked until the mutex becomes availab...
Definition: mutex_pthread.h:40
void broadcast_signal()
broadcast signal to unblock several threads waiting for the condition represented by this condition_m...
Definition: mutex_pthread.h:106
condition_mutex()
construct a mutex
Definition: mutex_pthread.h:80
void send_signal_with_lock()
prefered approach to send the signal and implemented as {lock();send_signal();unlock();}
Definition: mutex_pthread.h:98
~condition_mutex()
destruct a mutex
Definition: mutex_pthread.h:86
bool try_lock()
try to lock the mutex (return false if the mutex is still locked)
Definition: mutex_pthread.h:74
static unsigned get_debug_lock_counter()
return the global locking counter that is used for mutex debugging
Definition: mutex_pthread.h:21
the cgv namespace
Definition: vr_calib.cxx:9
void debug_unlock(const std::string &info)
same unlock but with printing debug information
Definition: mutex_pthread.h:64