class used to protect shared data from being simultaneously accessed by multiple threads.
More...
#include <semaphore.hpp>
|
| | Semaphore (size_t value=0) |
| | create an named semaphore.
|
| |
| | Semaphore (const std::string &name, size_t value=0, int oflag=O_CREAT, mode_t mode=0644) |
| | create a named semaphore.
|
| |
| | Semaphore (const Semaphore &other)=delete |
| | copy constructor.
|
| |
| Semaphore & | operator= (const Semaphore &other)=delete |
| | copy assignment operator.
|
| |
| | ~Semaphore () noexcept |
| | destroy instance.
|
| |
| void | post () noexcept |
| | increments the internal counter and unblocks acquirers.
|
| |
| void | wait () noexcept |
| | decrements the internal counter or blocks until it can
|
| |
| bool | tryWait () noexcept |
| | tries to decrement the internal counter without blocking.
|
| |
| template<class Rep , class Period > |
| bool | timedWait (std::chrono::duration< Rep, Period > timeout) |
| | tries to decrement the internal counter, blocking for up to a duration time.
|
| |
| int | value () noexcept |
| | get semaphore value.
|
| |
class used to protect shared data from being simultaneously accessed by multiple threads.
◆ Semaphore() [1/3]
| Semaphore::Semaphore |
( |
size_t | value = 0 | ) |
|
create an named semaphore.
- Parameters
-
◆ Semaphore() [2/3]
| Semaphore::Semaphore |
( |
const std::string & | name, |
|
|
size_t | value = 0, |
|
|
int | oflag = O_CREAT, |
|
|
mode_t | mode = 0644 ) |
create a named semaphore.
- Parameters
-
| name | semaphore name. |
| value | intial value. |
| oflag | control flag. |
| mode | open mode. |
◆ Semaphore() [3/3]
| join::Semaphore::Semaphore |
( |
const Semaphore & | other | ) |
|
|
delete |
copy constructor.
- Parameters
-
| other | other object to copy. |
◆ ~Semaphore()
| Semaphore::~Semaphore |
( |
| ) |
|
|
noexcept |
◆ operator=()
copy assignment operator.
- Parameters
-
| other | other object to assign. |
- Returns
- assigned object.
◆ post()
increments the internal counter and unblocks acquirers.
◆ timedWait()
template<class Rep , class Period >
| bool join::Semaphore::timedWait |
( |
std::chrono::duration< Rep, Period > | timeout | ) |
|
|
inline |
tries to decrement the internal counter, blocking for up to a duration time.
- Parameters
-
- Returns
- true on success, false otherwise.
◆ tryWait()
| bool Semaphore::tryWait |
( |
| ) |
|
|
noexcept |
tries to decrement the internal counter without blocking.
- Returns
- true on success, false otherwise.
◆ value()
get semaphore value.
- Returns
- -1 on error, semaphore value otherwise.
◆ wait()
decrements the internal counter or blocks until it can
◆ _named_handle
| sem_t* join::Semaphore::_named_handle |
◆ _unnamed_handle
| sem_t join::Semaphore::_unnamed_handle |
The documentation for this class was generated from the following files: