Wrapper around the Posix pthread_mutex_t C objects. More...
#include <mutex.hpp>
Public Member Functions | |
mutex () | |
constructor | |
~mutex () | |
destructor | |
void | lock () |
lock the mutex More... | |
void | unlock () |
unlock the mutex More... | |
bool | try_lock () |
Tells whether calling lock() would currently suspend the caller or not. More... | |
Wrapper around the Posix pthread_mutex_t C objects.
To protect a data against concurrent access by different threads each thread has to call the lock() method before and unlock() method after accessing that data. If another thread is already accessing that data calling lock() will suspended the calling thread up to the time the thread accessing the data calls unlock()
void libthreadar::mutex::lock | ( | ) |
lock the mutex
Referenced by libthreadar::tampon< T >::has_readable_block_next(), and libthreadar::tampon< T >::is_empty().
bool libthreadar::mutex::try_lock | ( | ) |
Tells whether calling lock() would currently suspend the caller or not.
void libthreadar::mutex::unlock | ( | ) |
unlock the mutex
Referenced by libthreadar::tampon< T >::has_readable_block_next(), and libthreadar::tampon< T >::is_empty().