Open francocipollone opened 1 year ago
Continuing the conversation from https://github.com/maliput/maliput_sparse/pull/52#discussion_r1098759204
I think it will play against us any potential parallelization we would like to use.
I don't think it will be a blocker for parallelization.
shared_ptr
s are thread-safe by implementation.
shared_ptr
s use atomic increments/decrements of a reference count value.nearest-neigbour
is queried.I still believe that using a shared_ptr
could be beneficial memory-wise and it will be thread-safe for the LineString.
Let me propose this use case:
With this context, we could make use of the adjacency property and reuse the same linestring, e.g: left linestring of lane 1 == right linestring of lane 2. As the underlying kdtree is under a shared_ptr, this line string will be copyable and the kdtree won't be necessary to be re-created: Better for timing, better for memory usage.
If we want to have this kind of memory management without using shared_ptr we should let the linestring to be owned by other entity (-> segment?) and correctly pass the raw pointer around. Also, the LineString is a pretty basic entity which is expected to be first instantiated by the parser and at that point a figure of "segment" won't be available until the lanes are identified into segments. So it isn't direct how to group the linestrings. From a user point of view, the use of LineString class is way less user-friendly with this last approach.
wdyt @agalbachicar
See https://github.com/maliput/maliput_sparse/pull/52#discussion_r1100765058 discussion
Summary
https://github.com/maliput/maliput_sparse/blob/471c19ddd0913522813569d835dc5b569d25ab14/include/maliput_sparse/geometry/line_string.h#L274
To keep in mind(from comments):