Galaxis Codebase
1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
mvector.hpp
Go to the documentation of this file.
1
#include <vector>
2
#include <mutex>
3
4
10
template
<
typename
T>
11
class
MutexedVectorPointer
{
12
private
:
13
std::vector<T>*
m_data
=
nullptr
;
14
std::mutex
m_mutex
;
15
16
public
:
17
MutexedVectorPointer
() =
delete
;
18
19
MutexedVectorPointer
(std::vector<T>& vec) {
20
m_data
= &vec;
21
}
22
23
MutexedVectorPointer
(std::vector<T>* vec) {
24
m_data
= vec;
25
}
26
27
std::vector<T>*
unmutexed_get_ptr
() {
28
return
m_data
;
29
}
30
31
void
push_back
(T
const
& item) {
32
m_mutex
.lock();
33
34
m_data
->push_back(item);
35
36
m_mutex
.unlock();
37
}
38
};
MutexedVectorPointer
This class holds a pointer onto a vector. Some of the std::vector functions are implemented for threa...
Definition:
mvector.hpp:11
MutexedVectorPointer::MutexedVectorPointer
MutexedVectorPointer()=delete
MutexedVectorPointer::MutexedVectorPointer
MutexedVectorPointer(std::vector< T > *vec)
Definition:
mvector.hpp:23
MutexedVectorPointer::m_mutex
std::mutex m_mutex
Definition:
mvector.hpp:14
MutexedVectorPointer::push_back
void push_back(T const &item)
Definition:
mvector.hpp:31
MutexedVectorPointer::m_data
std::vector< T > * m_data
Definition:
mvector.hpp:13
MutexedVectorPointer::MutexedVectorPointer
MutexedVectorPointer(std::vector< T > &vec)
Definition:
mvector.hpp:19
MutexedVectorPointer::unmutexed_get_ptr
std::vector< T > * unmutexed_get_ptr()
Definition:
mvector.hpp:27
utilities
include
utils
mvector.hpp
Generated by
1.8.17