Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* @file api.Semaphore.hpp |
3 |
|
|
* @author Sergey Baigudin, sergey@baigudin.software |
4 |
|
|
* @copyright 2015-2022, Sergey Baigudin, Baigudin Software |
5 |
|
|
*/ |
6 |
|
|
#ifndef API_SEMAPHORE_HPP_ |
7 |
|
|
#define API_SEMAPHORE_HPP_ |
8 |
|
|
|
9 |
|
|
#include "api.Object.hpp" |
10 |
|
|
|
11 |
|
|
namespace eoos |
12 |
|
|
{ |
13 |
|
|
namespace api |
14 |
|
|
{ |
15 |
|
|
|
16 |
|
|
/** |
17 |
|
|
* @class Semaphore |
18 |
|
|
* @brief Semaphore interface. |
19 |
|
|
*/ |
20 |
|
|
class Semaphore : public Object |
21 |
|
|
{ |
22 |
|
|
|
23 |
|
|
public: |
24 |
|
|
|
25 |
|
|
/** |
26 |
|
|
* @brief Destructor. |
27 |
|
|
*/ |
28 |
|
|
virtual ~Semaphore() = 0; |
29 |
|
|
|
30 |
|
|
/** |
31 |
|
|
* @brief Acquires one permit from this semaphore. |
32 |
|
|
* |
33 |
|
|
* The function acquires one permit or waits |
34 |
|
|
* while the permit will be released. |
35 |
|
|
* |
36 |
|
|
* @return True if the semaphore is acquired successfully. |
37 |
|
|
*/ |
38 |
|
|
virtual bool_t acquire() = 0; |
39 |
|
|
|
40 |
|
|
/** |
41 |
|
|
* @brief Releases one permit. |
42 |
|
|
* |
43 |
|
|
* The function releases from one permit and returns this to the semaphore. |
44 |
|
|
*/ |
45 |
|
|
virtual void release() = 0; |
46 |
|
|
|
47 |
|
|
}; |
48 |
|
|
|
49 |
|
32 |
inline Semaphore::~Semaphore() {} |
50 |
|
|
|
51 |
|
|
} // namespace api |
52 |
|
|
} // namespace eoos |
53 |
|
|
#endif // API_SEMAPHORE_HPP_ |
54 |
|
|
|