Represent a semaphore that can be used for interprocess communication.
More...
#include <be_process_semaphore.h>
|
| Semaphore (const std::string &name, const mode_t mode, const int value, const bool force=false) |
| Create a new named sempahore. More...
|
|
| Semaphore (const std::string &name) |
| Open an existing named sempahore. More...
|
|
| ~Semaphore () |
|
bool | wait (const bool interruptible) |
| Wait indefinitely for the semaphore to unblock. More...
|
|
bool | trywait (const bool interruptible) |
| Attempt to obtain the semaphore without blocking. More...
|
|
bool | timedwait (const uint64_t interval, const bool interruptible) |
| Attempt to obtain the semaphore while blocking for at most the specified time interval. More...
|
|
void | post () |
| Post (increment) to the semaphore. More...
|
|
std::string | getName () |
| Obtain the name of the Semaphore. More...
|
|
Represent a semaphore that can be used for interprocess communication.
Semaphores are shared counters with mutually exclusive modification properties. A counter value greater than zero means that a resource represented by the semaphore is available. A typical use is to grant exclusive access to a resource by allowing the counter to be valued at zero or one; this is known as a binary semaphore.
- Note
- The counter value is not exposed to clients of the object.
-
Because a Semaphore object wraps a system resource, the Semaphore can be passed to other functions, or inherited across a fork boundary.
Definition at line 42 of file be_process_semaphore.h.
◆ Semaphore() [1/2]
BiometricEvaluation::Process::Semaphore::Semaphore |
( |
const std::string & |
name, |
|
|
const mode_t |
mode, |
|
|
const int |
value, |
|
|
const bool |
force = false |
|
) |
| |
Create a new named sempahore.
- Parameters
-
[in] | name | The name of the semaphore, which must obey the syntax documented for the sem_open(2) call. If the semaphore already exists in the name space, construction will fail unless the force flag is true. In that case, the existing semaphore will be removed. |
[in] | mode | The permission mode of the semaphore. |
[in] | value | The initial value of the semaphore. |
[in] | force | The semaphore is created, disassociating an existing semaphore of the same name. |
- Exceptions
-
◆ Semaphore() [2/2]
BiometricEvaluation::Process::Semaphore::Semaphore |
( |
const std::string & |
name | ) |
|
Open an existing named sempahore.
- Parameters
-
[in] | name | The name of the semaphore, which must obey the syntax documented for the sem_open(2) call. |
- Exceptions
-
◆ ~Semaphore()
BiometricEvaluation::Process::Semaphore::~Semaphore |
( |
| ) |
|
◆ wait()
bool BiometricEvaluation::Process::Semaphore::wait |
( |
const bool |
interruptible | ) |
|
Wait indefinitely for the semaphore to unblock.
- Parameters
-
[in] | interruptible | true if the function should return if waiting was interrupted, false otherwise. |
- Returns
- true if the semaphore was obtained; false if not.
- Exceptions
-
◆ trywait()
bool BiometricEvaluation::Process::Semaphore::trywait |
( |
const bool |
interruptible | ) |
|
Attempt to obtain the semaphore without blocking.
- Parameters
-
[in] | interruptible | true if the function should return if waiting was interrupted, false otherwise. |
- Returns
- true if the semaphore was obtained; false if not.
- Exceptions
-
◆ timedwait()
bool BiometricEvaluation::Process::Semaphore::timedwait |
( |
const uint64_t |
interval, |
|
|
const bool |
interruptible |
|
) |
| |
Attempt to obtain the semaphore while blocking for at most the specified time interval.
- Parameters
-
[in] | interval | The max time to wait, in microseconds. |
[in] | interruptible | true if the function should return if waiting was interrupted, false otherwise. |
- Returns
- true if the semaphore was obtained; false if not.
- Exceptions
-
◆ post()
void BiometricEvaluation::Process::Semaphore::post |
( |
| ) |
|
Post (increment) to the semaphore.
- Exceptions
-
◆ getName()
std::string BiometricEvaluation::Process::Semaphore::getName |
( |
| ) |
|
Obtain the name of the Semaphore.
- Returns
- The name of the Sempahore.
The documentation for this class was generated from the following file: