-
Notifications
You must be signed in to change notification settings - Fork 69
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
refactor init to allow options to be passed and to not be global #154
Conversation
f8adb10
to
839cdc3
Compare
This generally looks good to me (afaict). I like the idea of not having Just a few things which came to my mind here:
|
Thanks for the feedback.
That's a good idea. I'll do that.
There is overlap between the two types, but neither is necessarily a superset of the other. I could choose to include the entire options structure in the context just for potential use in the future, but that's not necessary. For example, imagine an option like "do_not_register_signal_handlers", which is useful during init, but not necessarily afterwards, so it might not make it into the context by itself. But an option like
I don't think that's in scope here. Also these settings will probably not influence things like node names, topic names, etc., and so I'm not sure how important they are to playback. I think the key-value pairs might work for the options, but would be very efficient for accessing elements of the context. On the other hand, I don't think the key-value pair makes it possible to serialize them somehow where it was impossible before. So I think I'd pass on this for now. |
👍 to Regarding the |
Ok. My thinking was that there was one context per init, that's why I left init in the name. I thought of it like the init handle is analogous to the node handle or something like that. But I don't feel strongly about it, I'll drop the init.
Well they cannot, but the idea for now was that an rmw specific function could be used to "mutate" the implementation specific init options before passing them into the init. Doing so will tie you to a specific implementation. What this does enable, however, is to have code in the implementation of In the future, we might come up with a way to declare which ROS primitives you're going to create at the start (storing them in the init options) and then pass that to init, but not right now. This was talked about here: |
Thanks for clarifying. Sounds good to me. I just wanted to check I understood it correctly. Maybe adding a note in the docblock would be good - just to avoid users being unsure how to set options if they are not aware that it only works for rmw specific implementation? |
c5af0ee
to
990b92d
Compare
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.
LGTM
* \return `RMW_RET_OK` if the copy is successful, or | ||
* \return `RMW_RET_INCORRECT_RMW_IMPLEMENTATION` if the implementation | ||
* identifier for src does not match the implementation of this function, or | ||
* \return `RMW_RET_INVALID_ARGUMENT` if the dst has already be initialized, or |
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.
Consider adding another type: RMW_RET_OPTIONS_ALREADY_INIT
990b92d
to
2a363fb
Compare
LGTM |
9e12f3e
to
ff6c946
Compare
Signed-off-by: William Woodall <[email protected]>
Signed-off-by: William Woodall <[email protected]>
Signed-off-by: William Woodall <[email protected]>
Signed-off-by: William Woodall <[email protected]>
The two warnings on macOS are unrelated to my changes, so I'm going to merge! 🎉 |
The two new warning are caused by changes in ros2/rcl#336. Also in the latest packaging job: https://ci.ros2.org/job/ci_packaging_osx/59/warnings11Result/ The patch introduced new member to existing structs hence the initialization of these structs needs to be updated to initialize one more member. |
Ok, you're right, I assumed that the statement was unaffected by me because in C I'll fix it asap. |
See ros2/rcl#345, interestingly I don't see this warning on my macbook... |
…2#154) * refactor init to allow options to be passed and to not be global Signed-off-by: William Woodall <[email protected]> * use implementation identifier in init and shutdown functions Signed-off-by: William Woodall <[email protected]> * refactors and renames Signed-off-by: William Woodall <[email protected]> * refactor init_options into its own files Signed-off-by: William Woodall <[email protected]> Signed-off-by: Devin Bonnie <[email protected]>
tl;dr I would like reviews of the proposed changes to this API while I finish refactoring things up and down the stack to use this new API. So it's ready for review, but not for CI nor merge.
This pull request is motivated by new rmw implementations that require additional configuration during initialization.
This pull request makes two major changes:
rmw_init()
and then be accessed via a returnedrmw_init_context_t
instance, andrmw_init_context_t
allowsrmw_init()
to be non-globalThis also:
rmw_shutdown()
(previously referenced in documentation but never implemented)rmw_create_node()
andrmw_create_guard_condition()
functions to take thermw_init_context_t
as an argument, so they do not need to access global variablesI explicitly avoided refactoring
rmw_create_node()
to return a ret value rather than the pointer (so you can get more discrete error reasons) so I can do that when refactoring these interfaces to take allocators. I added a TODO in the meantime.