The project combines the fields of robotic path planning, computer vision and artificial intelligence, to be implemented as algorithms with the purpose of controlling a robot within a simulated environment.
3
stars
0
forks
source link
Make all custom types atomic with get() and get() methods #3
All custom types should be atomic by default, such that it's not required to manually used a mutex to have thread-safe access to the object data. Data should be updated using the .set() method, whereas accessing data atomically can be implemented in different ways.
For example, using the lidar_t lidar_data; object, accessing a the stored parameter range_max:
// unsafe
// .range_max is public
auto value = lidar_data.range_max;
// semi-safe
// tempated .get() method; .range_max is still public
auto value = lidar_data.get(lidar_data.range_max);
// safe
// manual get methods; .range_max is now private
auto value = lidar_data.get_range_max();
This can also be guaranteed by implementing std::atomic on the public members, such that individual access is guaranteed.
All custom types should be atomic by default, such that it's not required to manually used a mutex to have thread-safe access to the object data. Data should be updated using the
.set()
method, whereas accessing data atomically can be implemented in different ways.For example, using the
lidar_t lidar_data;
object, accessing a the stored parameterrange_max
:This can also be guaranteed by implementing
std::atomic
on the public members, such that individual access is guaranteed.