Skip to content
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

Make loaned messages const on the subscription side #1971

Open
wants to merge 2 commits into
base: rolling
Choose a base branch
from

Conversation

nnmm
Copy link
Contributor

@nnmm nnmm commented Jul 12, 2022

Related to ros2/rcl#992.

To make callback dispatching work, I generalized dispatch() to work with both const and non-const messages. Maybe there is a better way.

@ivanpauno ivanpauno added the enhancement New feature or request label Jul 12, 2022
Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to see some test cases before we merge this.

typename std::enable_if<std::is_same<ROSMessageType,
typename std::remove_const<MaybeConstROSMessageType>::type
>::value
>::type
dispatch(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add tests making sure that loaned messages work well with all types of callbacks?
There're a lot of codepaths here, and it's pretty hard to make sure you didn't break anything else.
So it would be nice to make sure all cases are covered in tests (some of the cases might already be covered).

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clalancette clalancette added the more-information-needed Further information is required label Jul 28, 2022
@nnmm
Copy link
Contributor Author

nnmm commented Sep 29, 2022

I've picked this up again – sorry for the delay.

Are you fine if I make it an error to dispatch a loaned message to a callback that would require making a copy of the loaned message? Because I think that making a copy would in most cases not be intended. But type adaptation should probably be allowed.

@ivanpauno
Copy link
Member

Are you fine if I make it an error to dispatch a loaned message to a callback that would require making a copy of the loaned message? Because I think that making a copy would in most cases not be intended.

I'm not sure.
It's true that if we don't do anything, users will probably no notice.
But it may also be strange to throw an exception.
Maybe logging a warning (?)

@wjwwood what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request more-information-needed Further information is required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants