Libthreadar
1.4.0
|
Wrapper around the Posix pthread_mutex_t C objects. More...
#include <mutex.hpp>
Inherited by libthreadar::condition.
Public Member Functions | |
mutex () | |
constructor | |
mutex (const mutex &ref)=delete | |
no copy constructor | |
mutex (mutex &&ref)=default | |
no move constructor | |
mutex & | operator= (const mutex &ref)=delete |
no assignment operator | |
mutex & | operator= (mutex &&ref) noexcept=default |
no move operator | |
virtual | ~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... | |
Protected Attributes | |
pthread_mutex_t | mut |
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().