cgv
|
A simple mutex (mutual exclusion) for solving thread synchronisation problems. More...
#include <mutex.h>
Public Member Functions | |
mutex () | |
construct a mutex | |
~mutex () | |
destruct a mutex | |
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 available) | |
void | unlock () |
unlock the mutex | |
void | debug_lock (const std::string &info) |
same as lock but with printing debug information | |
void | debug_unlock (const std::string &info) |
same unlock but with printing debug information | |
Static Public Member Functions | |
static unsigned | get_debug_lock_counter () |
return the global locking counter that is used for mutex debugging | |
Protected Attributes | |
void * | pmutex |
A simple mutex (mutual exclusion) for solving thread synchronisation problems.
cgv::os::mutex::mutex | ( | ) |
construct a mutex
Definition at line 27 of file mutex_pthread.h.
cgv::os::mutex::~mutex | ( | ) |
destruct a mutex
Definition at line 33 of file mutex_pthread.h.
void cgv::os::mutex::debug_lock | ( | const std::string & | info | ) |
same as lock but with printing debug information
Definition at line 52 of file mutex_pthread.h.
References get_debug_lock_counter(), lock(), and unlock().
void cgv::os::mutex::debug_unlock | ( | const std::string & | info | ) |
same unlock but with printing debug information
Definition at line 64 of file mutex_pthread.h.
|
static |
return the global locking counter that is used for mutex debugging
Definition at line 21 of file mutex_pthread.h.
Referenced by debug_lock().
void cgv::os::mutex::lock | ( | ) |
lock the mutex (if the mutex is already locked, the caller is blocked until the mutex becomes available)
lock the mutex (if the mutex is still locked, the caller is blocked until the mutex becomes available)
Definition at line 40 of file mutex_pthread.h.
Referenced by cgv::os::socket_server::bind_and_listen(), cgv::os::condition_mutex::broadcast_signal_with_lock(), cgv::os::socket_server::check_for_connection(), cgv::os::socket::close(), cgv::os::socket_client::connect(), debug_lock(), debug_unlock(), cgv::os::queued_output_thread::done(), cgv::os::queued_output_thread::get_nr_blocks(), cgv::os::queued_output_thread::get_nr_bytes(), cgv::os::queued_output_thread::has_connection(), cgv::os::socket::receive_line(), cgv::os::queued_output_thread::run(), cgv::os::queued_output_thread::send_block(), cgv::os::condition_mutex::send_signal_with_lock(), cgv::os::socket::set_last_error(), cgv::os::socket_server::wait_for_connection(), cgv::os::thread::wait_for_signal_or_timeout_with_lock(), and cgv::os::thread::wait_for_signal_with_lock().
bool cgv::os::mutex::try_lock | ( | ) |
try to lock the mutex (return false if the mutex is still locked)
Definition at line 74 of file mutex_pthread.h.
void cgv::os::mutex::unlock | ( | ) |
unlock the mutex
Definition at line 46 of file mutex_pthread.h.
Referenced by cgv::os::socket_server::bind_and_listen(), cgv::os::condition_mutex::broadcast_signal_with_lock(), cgv::os::socket_server::check_for_connection(), cgv::os::socket::close(), cgv::os::socket_client::connect(), debug_lock(), debug_unlock(), cgv::os::queued_output_thread::done(), cgv::os::queued_output_thread::get_nr_blocks(), cgv::os::queued_output_thread::get_nr_bytes(), cgv::os::queued_output_thread::has_connection(), cgv::os::socket::receive_line(), cgv::os::queued_output_thread::run(), cgv::os::queued_output_thread::send_block(), cgv::os::condition_mutex::send_signal_with_lock(), cgv::os::socket::set_last_error(), cgv::os::socket_server::wait_for_connection(), cgv::os::thread::wait_for_signal_or_timeout_with_lock(), and cgv::os::thread::wait_for_signal_with_lock().