Main Page
Namespaces
Classes
Files
File List
File Members
include
ram_path_planning
shemaphore.hpp
Go to the documentation of this file.
1
#ifndef RAM_PATH_PLANNING_SEMAPHORE_HPP
2
#define RAM_PATH_PLANNING_SEMAPHORE_HPP
3
4
#include <mutex>
5
6
namespace
ram_path_planning
7
{
8
class
Semaphore
9
{
10
private
:
11
unsigned
int
counter_
;
12
std::mutex
mutex_
;
13
std::condition_variable
condition_
;
14
15
public
:
16
inline
Semaphore
(
unsigned
int
counter) :
17
counter_(counter)
18
{
19
}
20
21
inline
void
wait
()
22
{
23
std::unique_lock<std::mutex> lock(mutex_);
24
condition_.wait(lock, [&]()->
bool
25
{
return
counter_>0;});
26
--
counter_
;
27
}
28
29
inline
void
signal
()
30
{
31
std::unique_lock<std::mutex> lock(mutex_);
32
++
counter_
;
33
condition_.notify_one();
34
}
35
};
36
37
}
38
39
#endif
ram_path_planning::Semaphore::condition_
std::condition_variable condition_
Definition:
shemaphore.hpp:13
ram_path_planning
Definition:
contours.hpp:6
ram_path_planning::Semaphore::wait
void wait()
Definition:
shemaphore.hpp:21
ram_path_planning::Semaphore::Semaphore
Semaphore(unsigned int counter)
Definition:
shemaphore.hpp:16
ram_path_planning::Semaphore::counter_
unsigned int counter_
Definition:
shemaphore.hpp:11
ram_path_planning::Semaphore::mutex_
std::mutex mutex_
Definition:
shemaphore.hpp:12
ram_path_planning::Semaphore
Definition:
shemaphore.hpp:8
ram_path_planning::Semaphore::signal
void signal()
Definition:
shemaphore.hpp:29
ram_path_planning
Author(s): Andres Campos - Institut Maupertuis
autogenerated on Mon Jun 10 2019 14:50:03