ORCA: Optimization-based framework for Robotic Control Applications
Main Page
Namespaces
Classes
Files
File List
File Members
include
orca
common
Mutex.h
Go to the documentation of this file.
1
//| This file is a part of the ORCA framework.
2
//|
3
//| Copyright 2018, Fuzzy Logic Robotics
4
//| Copyright 2017, ISIR / Universite Pierre et Marie Curie (UPMC)
5
//|
6
//| Main contributor(s): Antoine Hoarau, Ryan Lober, and
7
//| Fuzzy Logic Robotics <info@fuzzylogicrobotics.com>
8
//|
9
//| ORCA is a whole-body reactive controller framework for robotics.
10
//|
11
//| This software is governed by the CeCILL-C license under French law and
12
//| abiding by the rules of distribution of free software. You can use,
13
//| modify and/ or redistribute the software under the terms of the CeCILL-C
14
//| license as circulated by CEA, CNRS and INRIA at the following URL
15
//| "http://www.cecill.info".
16
//|
17
//| As a counterpart to the access to the source code and rights to copy,
18
//| modify and redistribute granted by the license, users are provided only
19
//| with a limited warranty and the software's author, the holder of the
20
//| economic rights, and the successive licensors have only limited
21
//| liability.
22
//|
23
//| In this respect, the user's attention is drawn to the risks associated
24
//| with loading, using, modifying and/or developing or reproducing the
25
//| software by the user in light of its specific status of free software,
26
//| that may mean that it is complicated to manipulate, and that also
27
//| therefore means that it is reserved for developers and experienced
28
//| professionals having in-depth computer knowledge. Users are therefore
29
//| encouraged to load and test the software's suitability as regards their
30
//| requirements in conditions enabling the security of their systems and/or
31
//| data to be ensured and, more generally, to use and operate it in the
32
//| same conditions as regards security.
33
//|
34
//| The fact that you are presently reading this means that you have had
35
//| knowledge of the CeCILL-C license and that you accept its terms.
36
37
#pragma once
38
39
#include <memory>
40
41
namespace
orca
42
{
43
namespace
common
44
{
45
struct
MutexInterface
46
{
47
virtual
~MutexInterface
() {}
48
virtual
void
lock
() = 0;
49
virtual
void
unlock
() = 0;
50
virtual
bool
trylock
() = 0;
51
};
52
53
class
Mutex
:
public
MutexInterface
54
{
55
public
:
56
Mutex
();
57
virtual
~
Mutex
();
58
void
lock
();
59
void
unlock
();
60
bool
trylock
();
61
private
:
62
struct
MutexImpl
;
63
std::shared_ptr<MutexImpl> pimpl;
64
};
65
66
class
MutexRecursive
:
public
MutexInterface
67
{
68
public
:
69
MutexRecursive
();
70
virtual
~
MutexRecursive
();
71
void
lock
();
72
void
unlock
();
73
bool
trylock
();
74
private
:
75
struct
MutexRecursiveImpl
;
76
std::shared_ptr<MutexRecursiveImpl> pimpl;
77
};
78
79
class
MutexLock
80
{
81
public
:
87
MutexLock
(
MutexInterface
&mutex_ )
88
: m_(mutex_)
89
{
90
m_.lock();
91
}
95
~MutexLock
()
96
{
97
m_.unlock();
98
}
99
100
protected
:
104
MutexInterface
&
m_
;
105
};
106
107
class
MutexTryLock
108
{
109
public
:
115
MutexTryLock
(
MutexInterface
&mutex )
116
: _mutex( mutex), successful( mutex.
trylock
() )
117
{
118
}
119
125
bool
isSuccessful
()
126
{
127
return
successful;
128
}
129
133
~MutexTryLock
()
134
{
135
if
( successful )
136
_mutex.unlock();
137
}
138
139
protected
:
143
MutexInterface
&
_mutex
;
144
145
private
:
149
bool
successful;
150
151
};
152
}
// namespace common
153
}
// namespace orca
orca::common::MutexInterface::trylock
virtual bool trylock()=0
orca::common::MutexTryLock
Definition:
Mutex.h:107
orca::common::Mutex::MutexImpl
Definition:
Mutex.cc:75
orca::common::MutexLock::m_
MutexInterface & m_
Definition:
Mutex.h:104
orca::common::Mutex
Definition:
Mutex.h:53
orca::common::MutexRecursive
Definition:
Mutex.h:66
orca::common::MutexTryLock::MutexTryLock
MutexTryLock(MutexInterface &mutex)
Definition:
Mutex.h:115
orca::common::MutexInterface
Definition:
Mutex.h:45
orca::common::MutexInterface::~MutexInterface
virtual ~MutexInterface()
Definition:
Mutex.h:47
orca::common::MutexInterface::unlock
virtual void unlock()=0
orca::common::MutexTryLock::~MutexTryLock
~MutexTryLock()
Definition:
Mutex.h:133
orca
Definition:
CartesianAccelerationPID.h:44
orca::common::MutexLock
Definition:
Mutex.h:79
orca::common::MutexRecursive::MutexRecursiveImpl
Definition:
Mutex.cc:92
orca::common::MutexLock::MutexLock
MutexLock(MutexInterface &mutex_)
Definition:
Mutex.h:87
orca::common::MutexInterface::lock
virtual void lock()=0
orca::common::MutexTryLock::_mutex
MutexInterface & _mutex
Definition:
Mutex.h:143
orca::common::MutexTryLock::isSuccessful
bool isSuccessful()
Definition:
Mutex.h:125
orca::common::MutexLock::~MutexLock
~MutexLock()
Definition:
Mutex.h:95
Generated by
1.8.11