8unsigned& ref_debug_lock_counter()
10 static unsigned counter = 0;
14mutex& 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);
void send_signal_with_lock()
prefered approach to send the signal and implemented as {lock();send_signal();unlock();}
~condition_mutex()
destruct a mutex
void send_signal()
send the signal to unblock a thread waiting for the condition represented by this condition_mutex
void broadcast_signal_with_lock()
prefered approach to broadcast the signal and implemented as {lock();broadcast_signal();unlock();}
void broadcast_signal()
broadcast signal to unblock several threads waiting for the condition represented by this condition_m...
condition_mutex()
construct a mutex
void unlock()
unlock the mutex
static unsigned get_debug_lock_counter()
return the global locking counter that is used for mutex debugging
void debug_unlock(const std::string &info)
same unlock but with printing debug information
bool try_lock()
try to lock the mutex (return false if the mutex is still locked)
void lock()
lock the mutex (if the mutex is already locked, the caller is blocked until the mutex becomes availab...
void debug_lock(const std::string &info)
same as lock but with printing debug information