|
Libthreadar 1.6.0
|
Wrapper around the Posix pthread_cond_t object and its associated mutex. More...
#include <condition.hpp>
Inherits libthreadar::mutex.
Public Member Functions | |
| condition (unsigned int num=1) | |
| constructor | |
| condition (const condition &ref)=delete | |
| no copy constructor | |
| condition (condition &&ref)=default | |
| no move constructor | |
| condition & | operator= (const condition &ref)=delete |
| no assignment operator | |
| condition & | operator= (condition &&ref) noexcept=default |
| no move operator | |
| ~condition () | |
| destructor | |
| void | wait (unsigned int instance=0) |
| put the calling thread on hold waiting for another thread to call signal() | |
| void | signal (unsigned int instance=0) |
| awakes a single thread suspended for having called wait() on the condition given in argument | |
| void | broadcast (unsigned int instance=0) |
| awakes all threads suspended for having called wait() on the condition given in argument | |
| unsigned int | get_waiting_thread_count (unsigned int instance=0) const |
| return the number of thread currently waiting on that condition | |
| Public Member Functions inherited from libthreadar::mutex | |
| 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 | |
| void | unlock () |
| unlock the mutex | |
| bool | try_lock () |
| Tells whether calling lock() would currently suspend the caller or not. | |
Additional Inherited Members | |
| Protected Attributes inherited from libthreadar::mutex | |
| pthread_mutex_t | mut |
Wrapper around the Posix pthread_cond_t object and its associated mutex.
Class condition inherits from the mutex class and thus provides the lock(), unlock() and try_lock() methods. These must be used around the wait(), signal() or broadcast() methods brought by this class, see details for each of them.
Definition at line 49 of file condition.hpp.
| libthreadar::condition::condition | ( | unsigned int | num = 1 | ) |
constructor
| [in] | num | number of instance to create, each instance is a separated condition relying on the same mutex. First instance starts with index 0 |
Referenced by condition(), condition(), operator=(), and operator=().
| void libthreadar::condition::broadcast | ( | unsigned int | instance = 0 | ) |
awakes all threads suspended for having called wait() on the condition given in argument
| [in] | instance | broadcast threads that have been waiting on that instance |
|
inline |
return the number of thread currently waiting on that condition
| [in] | instance | the condition instance number to count the waiting thread on |
Definition at line 105 of file condition.hpp.
| void libthreadar::condition::signal | ( | unsigned int | instance = 0 | ) |
| void libthreadar::condition::wait | ( | unsigned int | instance = 0 | ) |
put the calling thread on hold waiting for another thread to call signal()
| [in] | instance | the instance number to have the caller waiting on |