Libthreadar 1.6.0
|
Class freezer is a semaphore like construct that has no maximum value. More...
#include <freezer.hpp>
Public Member Functions | |
freezer () | |
freezer constuctor | |
freezer (const freezer &ref)=delete | |
no copy constructor | |
freezer (freezer &&ref)=default | |
no move constructor | |
freezer & | operator= (const freezer &ref)=delete |
no assignment operator (made private) | |
freezer & | operator= (freezer &&ref) noexcept=default |
no move operator | |
~freezer () | |
Destructor. | |
bool | waiting_thread () const |
Return whether the freezer has at least a pending thread waiting for another thread to unlock it. | |
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 freezer. | |
int | get_value () const |
Return the value of the freezer, that's to say the number of available "resources". More... | |
Class freezer is a semaphore like construct that has no maximum value.
initialized with a value of zero, any call to lock() reduces the value by one, any call to unlock() increases it by one. A call to lock() when the current value is zero or less suspends the calling thread. A call to unlock() when at least one thread is suspended on the freezer awakes exactly one thread. A call to unlock() when the freezer value is zero or more does only increase the value, the calling thread is not blocked.
Definition at line 54 of file freezer.hpp.
|
inline |
Return the value of the freezer, that's to say the number of available "resources".
Definition at line 99 of file freezer.hpp.
void libthreadar::freezer::lock | ( | ) |
Request a "resource".
If the freezer value is zero or less, lock() reduces the freezer by one and suspends the calling thread. If the freezer value is strictly greater than zero, it only reduces the freezer value by one, the calling thread is not locked.
void libthreadar::freezer::unlock | ( | ) |
Release a "resource".
increase the freezer value by one. If at least one thread was suspended on the freezer, exactly one thread is awaken