-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
[Core]: Replace raw pointers with smart pointers for CFs #258
Conversation
ad61555
to
b946a2e
Compare
Also as a more general note on tests, I noticed some unexpected behavior with the tests, where they sometimes fail and sometimes don't. I suspect the problem being that they currently all share the singleton #161 might be able to fix this. Since it again will be a really disruptive change, I can work on it this weekend if wanted, that way we do all the major disruptive changes in a time-span as short as possible. |
I think the tests sometimes fail because the network manager is being updated from the hardware layer while tests are also manually updating it, causing some race conditions within the tests. I think many of those issues could be fixed by having a way to turn on and off the periodic updates for the network manager. You've been writing a lot of code recently, haha! Glad to have you back. I am traveling right now, so I haven't been contributing a ton. If you are interested in taking a swing at that, I agree it might be good to get major refactors out of the way sooner rather than later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One warning here:
Can probably just delete the parameter name of |
I'll check. I was able to run the VT3 object pool example successfully before making this PR. But that was just loading it in as a saved version on the VT.
Sounds good! Unfortunately, I have a very busy week and a half ahead of me, so that means less coding for me... But hopefully at the end I'll have some footage of a real world application using this stack :) |
In my case it fails on the ETP session: Though this still doesn't explain why you don't even get a transport session started... Maybe a candump will tell more? |
b946a2e
to
7367781
Compare
7367781
to
2373f46
Compare
Side note, we might be able to remove the approve step on these workflows, as I enabled the ability to allow forks to run our workflows and pull in the variable needed for sonar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything seems to be running okay with your latest code, I was able to run all the VT examples with and without transferring the pools. But I worry a little bit about requiring people to destroy
their ICFs or Partners... if one goes out of scope without destroy
being called it doesn't get replaced by an external CF in the case of partners, and remains in the table and functional in the case of an ICF... I am wondering if we need to consider calling destroy in the destructor if it wasn't called otherwise, or at the very least log an error that it was improperly handled? I am wondering what your thoughts are on this.
Since CANManager uses We could opt for using
I didn't like the confusion that arises when you need to keep the 'owner' What are your thoughts one this? |
Hmm, yeah we'd almost have to save a weak pointer or similar in every CF back to the manager to do anything useful... which is a lot of overhead.
Yeah, I don't think that would be worth it... adds overhead as well to scan the table for expired weak pointers to prune them.
Actually that's a fair point, it's probably more arcane that users have to keep the return values from EventDispatcher around than it is to say the the manager has to own the control functions... I suppose you've convinced me, haha. On a side topic, if we're moving that way towards the manager being the owner, we'll probably have to do some work in #161 to make what is currently |
I have made a good start on refactoring the CANNetworkManager a few weeks ago, I can already make a draft PR for your initial thoughts on it |
Nevermind, since the base branch of this PR is still on my fork, we can't compare to it on a draft PR. This link should do the trick instead: GwnDaan/AgIsoStack-plus-plus@smart-pointer-cfs...GwnDaan:ISO11783-CAN-Stack:remove-network-manager-singleton Note how it still is very much work-in-progress. There is still a lot of classes to adapt to the new approach, but the core functionality should be almost complete. Namely the CANNetworkManager/TP/ETP/FP/CF's/AddressClaimStateMachine |
2373f46
to
5581560
Compare
IIRC forks shouldn't have access to those variables, because of security reasons, or has that changed since we initially introduced this 'approve' thingy? Though I image we can remove the approve environment step if I develop on branches directly in this repo instead. |
IIRC it just allows them to run our workflows from a fork, and doesn't allow them to see the actual values, but developing on this repo directly is probably the best/easiest and keeps that kind of stuff as safe as it can be. I'll go back through and change it. I agree that the environment approval can probably be removed. We will always get asked to approve workflows from new contributors at least. |
8217d79
to
8509d07
Compare
8509d07
to
51e5706
Compare
Hi @ad3154, this took a while, but I think I finally got it now. I made sure that #192 is still working properly. This PR will probably be a little harder to review, sorry for that. Any feedback is welcome. I felt like and kind of still feel like the |
With this change all the current raw pointers are converted to smart pointers, e.g. `shared_ptr`
51e5706
to
41c51d9
Compare
SonarCloud Quality Gate failed. 0 Bugs 43.5% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty good I think! Pretty big change, but a step in a better direction overall.
I also agree with your comments about the network manager needing some cleanup at some point.
Closes #257, but is based on #255
I choose to go with the
shared_ptr
approach instead of theweak_ptr
approach. The main reason being that it might be really confusing and hard to debug why a control function suddenly stopped working when usingweak_ptr
and they invalidate when the created ownershared_ptr
goes out of scope.What changed
shared_ptr
) for the internal/external/partnered control functionsactiveControlFunctions
as we can already iterate over the array in the controlFunctionTable.shared_ptr
being created and manage it in CANNetwork accordingly.destroy()
function to CF's to allow for removal of the CF from the network manager