Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
rtt
os
Semaphore.hpp
Go to the documentation of this file.
1
/***************************************************************************
2
tag: Peter Soetens Tue Apr 5 16:53:24 CEST 2005 Semaphore.hpp
3
4
Semaphore.hpp - description
5
-------------------
6
begin : Tue April 05 2005
7
copyright : (C) 2005 Peter Soetens
8
email : peter.soetens@mech.kuleuven.ac.be
9
10
***************************************************************************
11
* This library is free software; you can redistribute it and/or *
12
* modify it under the terms of the GNU General Public *
13
* License as published by the Free Software Foundation; *
14
* version 2 of the License. *
15
* *
16
* As a special exception, you may use this file as part of a free *
17
* software library without restriction. Specifically, if other files *
18
* instantiate templates or use macros or inline functions from this *
19
* file, or you compile this file and link it with other files to *
20
* produce an executable, this file does not by itself cause the *
21
* resulting executable to be covered by the GNU General Public *
22
* License. This exception does not however invalidate any other *
23
* reasons why the executable file might be covered by the GNU General *
24
* Public License. *
25
* *
26
* This library is distributed in the hope that it will be useful, *
27
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
28
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29
* Lesser General Public License for more details. *
30
* *
31
* You should have received a copy of the GNU General Public *
32
* License along with this library; if not, write to the Free Software *
33
* Foundation, Inc., 59 Temple Place, *
34
* Suite 330, Boston, MA 02111-1307 USA *
35
* *
36
***************************************************************************/
37
38
39
40
41
#ifndef RTT_OS_SEMAPHORE_HPP
42
#define RTT_OS_SEMAPHORE_HPP
43
44
#include "
fosi.h
"
45
#include "../rtt-config.h"
46
#include "../Time.hpp"
47
48
namespace
RTT
49
{
namespace
os {
61
class
RTT_API
Semaphore
62
{
63
private
:
64
rt_sem_t
sem
;
65
public
:
70
Semaphore
(
int
count)
71
{
72
rtos_sem_init
( &sem, count );
73
}
74
78
~Semaphore
()
79
{
80
rtos_sem_destroy
( &sem );
81
}
82
87
void
wait
()
88
{
89
rtos_sem_wait
( &sem );
90
}
91
96
void
signal
()
97
{
98
rtos_sem_signal
( &sem );
99
}
100
106
bool
trywait
()
107
{
108
if
(
rtos_sem_trywait
( &sem ) == 0 )
109
return
true
;
110
return
false
;
111
}
112
116
#ifndef OROPKG_OS_MACOSX
117
int
value
()
118
{
119
return
rtos_sem_value
( &sem );
120
}
121
#endif
122
};
123
}}
124
125
#endif
RTT::os::Semaphore::signal
void signal()
Definition:
Semaphore.hpp:96
RTT::os::Semaphore::sem
rt_sem_t sem
Definition:
Semaphore.hpp:64
RTT::os::Semaphore::value
int value()
Definition:
Semaphore.hpp:117
rtos_sem_trywait
int rtos_sem_trywait(rt_sem_t *m)
rtos_sem_signal
int rtos_sem_signal(rt_sem_t *m)
RTT::os::Semaphore
Definition:
Semaphore.hpp:61
RTT::os::Semaphore::Semaphore
Semaphore(int count)
Definition:
Semaphore.hpp:70
RTT::os::Semaphore::~Semaphore
~Semaphore()
Definition:
Semaphore.hpp:78
fosi.h
RTT::os::Semaphore::wait
void wait()
Definition:
Semaphore.hpp:87
rtos_sem_destroy
int rtos_sem_destroy(rt_sem_t *m)
rtos_sem_init
int rtos_sem_init(rt_sem_t *m, int value)
rtos_sem_value
int rtos_sem_value(rt_sem_t *m)
RTT
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition:
Activity.cpp:53
RTT::os::Semaphore::trywait
bool trywait()
Definition:
Semaphore.hpp:106
rtos_sem_wait
int rtos_sem_wait(rt_sem_t *m)
rt_sem_t
cyg_sem_t rt_sem_t
Definition:
ecos/fosi.h:143
rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:27