-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transition to standard smart pointers #2792
Comments
Other than lack of consistency and ease of migration, I'm failing to grasp the motive behind your increased concern. What's the failure case you have in mind? Other than that the plans sounds good. |
I still don't reached my target to cleanup code this far, that I can cleanup CMake code. So maybe I will replace only small parts of boost, but not the big things. In general it could be hard to be fully compatible to 1.9.1. |
No, I don't have other concerns besides migration. So by "this is bad" I rather meant "this is bad when it comes to migration". Consider this public API method: pcl/surface/include/pcl/surface/surfel_smoothing.h Lines 96 to 99 in 99a5b28
It uses boost::shared_ptr<std::vector<int>> output_features(new std::vector<int>);
obj.extractSalientFeaturesBetweenScales(cloud, normals, output_features); Now suppose we switch to
I was not talking about CMake here, only code.
Also not other Boost classes. Let's keep this issue focused on smart pointers. |
Thanks for the clarification. For cases like the one you mentioned. I would opt to simply do the breaking transition without a deprecation cycle because I really do not want to have if/else guards all around. |
Will there be future installments or is this task complete for 1.10 checklist? |
This task is by no means complete, but I'm currently struggling to find time to finish this. I'll try to have another look at it and put together a list of remaining work items. |
The latest devel version of PCL implementes the change describes in PointCloudLibrary/pcl#2792 That is, Boost smart pointers are replaced with standard smart pointers. This seems to be breaking the compilation of the code in this repository. By fixing the version to 1.9.1 the issue should be solved.
Most private replacements are now done. I haven't gone through the examples/tools/apps yet. I suspect that most uses of shared pointers in those apps are to interface with our public API.
|
I wanted to ask if it makes sense to add another level of indirection in the smart pointer names. We are already using ProposalCreate |
I understand the idea, but I don't get what are the benefits. With the current plan we'll eventually have a commit which replaces |
I would rather propose to switch to more meaningful and flexible semantics. There's a huge section in C++ Core Guidelines dedicated to smart pointers. Take also a look at: The problem is by using |
I assumed having only one shared_ptr would help in providing one consistent class for shared_ptr. That one line can also be patched and then pcl redistributed to work in other environments. We already have a In future, this approach also allows customization points such as Eigen has some nice compile time customization points that I like (but don't make sense for PCL, just giving a comparison) For the future: If someone wants to use PCL with custom internals (say boost pointers), they can supply an otherwise generated file say
@deni64k I don't think it's possible before the 1.10 release. You should start an independent discussion regarding those changes being accepted after this release for PCL 1.11 or for PCL 2.0 (PCL 2 is essentially rewritten PCL with modern semantics for an API). Time is rather scarce right now. |
|
A follow-up from ethz-asl/pcl_catkin#20 (comment)
I believe this is not possible anymore for Edit: I just remembered chat we had in the past about API visibility. I argued that as long as it is usable and visible to the users, they would use it and thus putting things inside |
It's true that such an approach won't work. But in my opinion, this does not mean that we should give up on preserving compatibility. I did not study that code in Ideally, we need to break this knot. But, as usual, there are other priorities at the moment, so it's not gonna happen soon. Now that we know that
Well, I still stand by this. I would mercilessly break any code that uses |
With #3497 merged I will now start performing changes in the public api. |
Sounds good to me 👍
What about this though? |
I believe the same argument can be made in reverse. If it only breaks one consumer, why are we not simply breaking the API for this one case. I would rather have pcl_ros update its interface based on our exported version and let the project handle this from their side than leaving a boost shared pointer and header in our most used class. Ultimately they are using a method from a I still believe that API breakage will be inevitable and between doing it in two separate occasions or simply doing it now, I would rather do it now. That being said. I don't have a strong opinion about this. I would still would like to see proposals for a good deprecation strategy. But if there end up being none, we might as well rupture things now. |
I'm just not sure how well-maintained |
Currently, Serializer caches computed message field mapping in a protected field [1] of pcl::PointCloud<T> class. This commit adds a static field to the Serializer class and stores the mapping there instead. Motivation: as a part of boost::shared_ptr -> std::shared_ptr migration in PCL [2] we have changed the type of the aforementioned protected field. Later on we were informed that this broke pcl_ros. This was unexpected since the field and the associated accessor function are not a public API. After some investigation we came to conclusion that pcl_ros is probably the only user of that field. With this in mind, we'd like to get rid of it altogether. Therefore, this commit serves two purposes: unbreak pcl_ros for PCL master and get rid of the dependency on non-public API that is going to be deprecated/removed soon. References: [1] https://github.com/taketwo/pcl/blob/0a6508ab6c18b5adff3aaf6ef1d2884647f9acba/common/include/pcl/point_cloud.h#L606 [2] PointCloudLibrary/pcl#2792
Currently, Serializer caches computed message field mapping in a protected field [1] of pcl::PointCloud<T> class. This commit adds a static variable to the Serializer::read() method and stores the mapping there instead. Motivation: as a part of boost::shared_ptr -> std::shared_ptr migration in PCL [2] we have changed the type of the aforementioned protected field. Later on we were informed that this broke pcl_ros. This was unexpected since the field and the associated accessor function are not a public API. After some investigation we came to conclusion that pcl_ros is probably the only user of that field. With this in mind, we'd like to get rid of it altogether. Therefore, this commit serves two purposes: unbreak pcl_ros for PCL master and get rid of the dependency on non-public API that is going to be deprecated/removed soon. References: [1] https://github.com/taketwo/pcl/blob/0a6508ab6c18b5adff3aaf6ef1d2884647f9acba/common/include/pcl/point_cloud.h#L606 [2] PointCloudLibrary/pcl#2792
We had a few smart pointers related discussions and updates in various places, I'll try to summarize everything here and outline the next steps. @PointCloudLibrary/maintainers please 👍/👎 this so we can move on with the release as soon as possible.
In #2772 (see #2772 (comment) and ensuing comments) there was a rough consensus that the transition should not happen before 1.10. Once the release is done we'll switch to
Earlier in this thread (see #2792 (comment)) @kunaltyagi proposed to introduce
Also earlier in this thread (see #2792 (comment)) we discussed the breakage of API that |
* Add static message field mapping to Serializer class Currently, Serializer caches computed message field mapping in a protected field [1] of pcl::PointCloud<T> class. This commit adds a static variable to the Serializer::read() method and stores the mapping there instead. Motivation: as a part of boost::shared_ptr -> std::shared_ptr migration in PCL [2] we have changed the type of the aforementioned protected field. Later on we were informed that this broke pcl_ros. This was unexpected since the field and the associated accessor function are not a public API. After some investigation we came to conclusion that pcl_ros is probably the only user of that field. With this in mind, we'd like to get rid of it altogether. Therefore, this commit serves two purposes: unbreak pcl_ros for PCL master and get rid of the dependency on non-public API that is going to be deprecated/removed soon. References: [1] https://github.com/taketwo/pcl/blob/0a6508ab6c18b5adff3aaf6ef1d2884647f9acba/common/include/pcl/point_cloud.h#L606 [2] PointCloudLibrary/pcl#2792 * Remove DefaultMessageCreator specialization for PointCloud The mapping between message data and object fields is now stored in Serializer, so there is no need to use pcl::detail::getMapping()
Now that PCL compiles with C++14 by default, it's high time to make a transition from Boost to standard smart pointers. This transition should not break source code level compatibility with previous releases. In other words, users should be able to compile their downstream projects with both PCL 1.9 and PCL master.
Grepping for
shared_ptr
in PCL code base I find well over a thousand matches. We can divide these in two groups: where it is a part of public API and where it is not. For the second group the transition is straightforward. For the first group... it depends. As far as I can see, not all shared pointers in API are hidden behindtypedef
s. This is bad. We will need to think about it and come up with a good strategy how to smoothly convert these.In the meantime, as a first step I propose to take care of the non-API shared pointers. I think it's not purely mechanical change and we'd always need to carefully double check the context. So I see this as a series of medium-sized PRs. This way it's a) not as daunting a task to do actual changes b) and to review; c) plus we'll have fewer conflicts with other PRs, especially the modernization ones that tend to produce large scattered diffs.
I can (slowly) start with this. @SunBlack your help would surely be appreciated if you are interested. We'll need to orchestrate our efforts to avoid conflicts and double work.
The text was updated successfully, but these errors were encountered: