Libthreadar 1.6.0
|
Class semaphore is an enhanced version of Posix semaphore. More...
#include <semaphore.hpp>
Public Member Functions | |
semaphore (unsigned int max_value) | |
semaphore constuctor More... | |
semaphore (const semaphore &ref)=delete | |
no copy constructor | |
semaphore (semaphore &&ref) noexcept=default | |
no move constructor | |
semaphore & | operator= (const semaphore &ref)=delete |
no assignment operator | |
semaphore & | operator= (semaphore &&ref) noexcept=default |
no move operator | |
~semaphore () | |
Destructor. | |
bool | waiting_thread () const |
Return whether the semaphore has at least a pending thread waiting for another thread to unlock it. | |
bool | working_thread () const |
return whether the semaphore has at least one thread that acquired the lock, possibily without other thread pending | |
void | lock () |
Request a "resource". More... | |
void | unlock () |
Release a "resource". More... | |
void | reset () |
Reset to initial state releasing any thread that could wait on the semaphore. | |
int | get_value () const |
Return the value of the semaphore, that's to say the number of available "resources". More... | |
Class semaphore is an enhanced version of Posix semaphore.
In addition to Posix Semaphore, this class let the calling thread able to know whether other thread than the one currently having the lock are waiting for the semaphore to be released
Definition at line 52 of file semaphore.hpp.
libthreadar::semaphore::semaphore | ( | unsigned int | max_value | ) |
semaphore constuctor
[in] | max_value | is the maximum number of thread that can concurrently call lock() without being suspended |
|
inline |
Return the value of the semaphore, that's to say the number of available "resources".
Definition at line 111 of file semaphore.hpp.
void libthreadar::semaphore::lock | ( | ) |
Request a "resource".
void libthreadar::semaphore::unlock | ( | ) |