include
ecl
ipc
semaphore_pos.hpp
Go to the documentation of this file.
1
8
/*****************************************************************************
9
** Ifdefs
10
*****************************************************************************/
11
12
#ifndef ECL_IPC_SEMAPHORE_POS_HPP_
13
#define ECL_IPC_SEMAPHORE_POS_HPP_
14
15
/*****************************************************************************
16
** Platform Check
17
*****************************************************************************/
18
19
#include <
ecl/config.hpp
>
20
#if defined(ECL_IS_POSIX)
21
#include <unistd.h>
22
#ifdef _POSIX_SEMAPHORES
23
#if _POSIX_SEMAPHORES > 0
24
25
/*****************************************************************************
26
** Ecl Functionality Defines
27
*****************************************************************************/
28
29
#ifndef ECL_HAS_POSIX_SEMAPHORES
30
#define ECL_HAS_POSIX_SEMAPHORES
31
#endif
32
#ifndef ECL_HAS_SEMAPHORES
33
#define ECL_HAS_SEMAPHORES
34
#endif
35
36
/*****************************************************************************
37
** Includes
38
*****************************************************************************/
39
40
#include <iostream>
41
#include <string>
42
#include <semaphore.h>
43
#include <fcntl.h>
/* For O_* constants */
44
#include <
ecl/exceptions/standard_exception.hpp
>
45
#include <
ecl/time/duration.hpp
>
46
47
/*****************************************************************************
48
** Namespaces
49
*****************************************************************************/
50
51
namespace
ecl
{
52
53
/*****************************************************************************
54
** Forward Declarations
55
*****************************************************************************/
56
57
class
Semaphore;
58
59
#ifdef ECL_HAS_EXCEPTIONS
60
61
namespace
ipc {
62
63
/*****************************************************************************
64
** Semaphore Exceptions
65
*****************************************************************************/
75
ECL_LOCAL
ecl::StandardException
openSemaphoreException(
const
char
* loc );
85
ECL_LOCAL
ecl::StandardException
tryLockSemaphoreException(
const
char
* loc);
86
87
}
// namespace ipc
88
89
#endif
/* ECL_HAS_EXCEPTIONS */
90
91
/*****************************************************************************
92
** Semaphores
93
*****************************************************************************/
110
class
ECL_PUBLIC
Semaphore
111
{
112
public
:
113
/*********************
114
** C&D's
115
**********************/
123
Semaphore();
136
Semaphore(
const
std::string& string_id);
142
virtual
~Semaphore();
143
144
/*********************
145
** Locking
146
**********************/
152
void
lock();
158
void
unlock();
165
bool
trylock();
181
bool
trylock(
const
Duration
&timeout );
182
183
private
:
184
std::string name;
185
sem_t* semaphore;
186
193
int
count();
194
};
195
196
197
}
// namespace ecl
198
199
200
#endif
/* _POSIX_SEMAPHORES > 0 */
201
#endif
/* _POSIX_SEMAPHORES */
202
#endif
/* ECL_IS_POSIX */
203
204
#endif
/* ECL_IPC_SEMAPHORE_POS_HPP_ */
ecl
Embedded control libraries.
config.hpp
duration.hpp
ecl::StandardException
Duration
TimeStamp Duration
standard_exception.hpp
ECL_LOCAL
#define ECL_LOCAL
ECL_PUBLIC
#define ECL_PUBLIC
ecl_ipc
Author(s): Daniel Stonier
autogenerated on Mon Feb 28 2022 22:18:31