-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
ModuleBase add common base and cleanup #12191
Conversation
1132046
to
0dc6c24
Compare
0dc6c24
to
8b5862b
Compare
@bkueng and @julianoes could I get some initial feedback? I originally did this last year, so I need to review it myself... |
src/platforms/common/module.cpp
Outdated
// search for module again to request stop | ||
object = get_module_instance(name); | ||
|
||
if (object != nullptr) { |
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.
This is a bit confusing because there are checks for object != nullptr
in several places.
Could you invert the logic to:
object = get_module_instance(name);
if (object == nullptr) {
break;
...
And with a scoped lock you could even get rid of the do
while
and just return
directly.
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.
The locking and structure is a bit weird because it's expecting the task to kill itself cleanly, so it's sleeping, checking, etc in between.
I'll review it again.
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.
I still think you could turn that around for better readability.
The design looks ok - I initially went for a stronger separation between tasks, but since we're generally moving away from that, this works too. |
04d9d6b
to
48a2d8d
Compare
e3c9f40
to
ce71d52
Compare
5cac8ca
to
b3bad51
Compare
70c3f18
to
b6e56d8
Compare
@bkueng @julianoes can we regroup and start going through this again? It saves a relatively large amount of flash (> 5 kB on fmu-v2) and sets us up for taking the next step in running multiple instances of certain modules (eg multi-EKF). Notes:
|
b6e56d8
to
3700b55
Compare
I will need to go through that in detail. Meanwhile can you check again, I think some of my previous remarks are not resolved yet. |
3700b55
to
e327c07
Compare
e327c07
to
72a205b
Compare
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
Closing as stale. |
This PR updates
ModuleBase<T>
(px4_module.h) to have a non-template base classModuleBaseInterface
. Then instead of each module having a static _object pointer there's a single LinkedList.Then methods like
ModuleBase<T>::stop_command()
have been refactored so that the bulk of the code is common, with each module frontend finding its object pointer by name from the LinkedList, rather than statically. Getting the bulk of this code out of the template is where flash is saved.This is an incremental step towards expanding ModuleBase to optionally handle multiple instances of a module.