NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
be_process_semaphore.h
Go to the documentation of this file.
1/*
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 */
10
11#ifndef __BE_PROCESS_SEMAPHORE_H__
12#define __BE_PROCESS_SEMAPHORE_H__
13
14#include <sys/types.h>
15#include <semaphore.h>
16#include <stdint.h>
17
18#include <string>
19
20namespace BiometricEvaluation
21{
22 namespace Process
23 {
43 {
44 public:
68 const std::string &name,
69 const mode_t mode,
70 const int value,
71 const bool force = false);
72
85 const std::string &name);
86
88
102 bool wait(const bool interruptible);
103
117 bool trywait(const bool interruptible);
118
139 const uint64_t interval,
140 const bool interruptible);
141
150 void post();
151
159 std::string getName();
160
161 protected:
162
163 private:
165 sem_t * _semaphore;
166 std::string _name;
167 pid_t _creatorPID;
168 };
169 }
170}
171
172#endif /* __BE_PROCESS_SEMAPHORE_H__ */
173
Represent a semaphore that can be used for interprocess communication.
Semaphore(const std::string &name)
Open an existing named sempahore.
void post()
Post (increment) to the semaphore.
bool trywait(const bool interruptible)
Attempt to obtain the semaphore without blocking.
std::string getName()
Obtain the name of the Semaphore.
Semaphore(const std::string &name, const mode_t mode, const int value, const bool force=false)
Create a new named sempahore.
bool wait(const bool interruptible)
Wait indefinitely for the semaphore to unblock.
bool timedwait(const uint64_t interval, const bool interruptible)
Attempt to obtain the semaphore while blocking for at most the specified time interval.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...