rmw_fastrtps_shared_cpp
master
Code shared on static and dynamic type support of rmw_fastrtps_cpp.
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
_
c
d
j
r
Functions
_
c
d
j
r
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
g
h
i
l
m
o
p
r
s
t
w
~
Functions
a
c
d
g
h
m
o
p
r
s
t
w
~
Variables
b
c
d
i
l
m
p
r
s
t
w
Files
File List
File Members
All
Functions
Variables
Typedefs
Macros
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
include
rmw_fastrtps_shared_cpp
locked_object.hpp
Go to the documentation of this file.
1
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef RMW_FASTRTPS_SHARED_CPP__LOCKED_OBJECT_HPP_
16
#define RMW_FASTRTPS_SHARED_CPP__LOCKED_OBJECT_HPP_
17
18
#include <mutex>
19
20
#include "
rcpputils/thread_safety_annotations.hpp
"
21
22
template
<
class
T>
23
class
LockedObject
24
{
25
private
:
26
mutable
std::mutex
mutex_;
27
T object_ RCPPUTILS_TSA_GUARDED_BY(mutex_);
28
29
public
:
33
std::mutex
&
getMutex
() const RCPPUTILS_TSA_RETURN_CAPABILITY(mutex_)
34
{
35
return
mutex_;
36
}
37
38
T &
operator()
()
39
{
40
return
object_;
41
}
42
43
const
T &
operator()
()
const
44
{
45
return
object_;
46
}
47
};
48
49
#endif // RMW_FASTRTPS_SHARED_CPP__LOCKED_OBJECT_HPP_
LockedObject::getMutex
std::mutex & getMutex() const RCPPUTILS_TSA_RETURN_CAPABILITY(mutex_)
Definition:
locked_object.hpp:33
LockedObject::operator()
const T & operator()() const
Definition:
locked_object.hpp:43
LockedObject::operator()
T & operator()()
Definition:
locked_object.hpp:38
LockedObject
Definition:
locked_object.hpp:23
thread_safety_annotations.hpp
std::mutex
Generated by
1.8.17