Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
I'm concerned this isn't the right fix, @guillaumeautran why did you not change the destructor of
AnyExecutable
instead?Just changing the callback group to
nullptr
is fragile. There's nothing in the destructor ofAnyExecutable
which implies the callback group might be reset to affect behavior.Instead, I think, at the very least,
AnyExecutable
should have had a boolean likeshould_reset_can_be_taken_from_automatically
which defaulted to true, and the multi threaded executor could change to false. Then it's clearer from both the multi threaded executor's code and any executable's code what's happening.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 was not sure if there was a specific reason why the destructor was setup the way it was and did not want to run the risk of leaving the group "locked". I'll make the requested changes then and push another PR.
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.
It's possible that since this exists:
https://github.com/ros2/rclcpp/blob/master/rclcpp/src/rclcpp/executor.cpp#L288
We should just remove the code in the destructor of
AnyExecutable
that changes thecan_be_taken_from
of the callback group.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.
@wjwwood Do you think I can add an argument to the constructor of the
AnyExecutable
class?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 would be hesitant from removing the if statement. There is a comment that makes a lot of sense:
rclcpp/rclcpp/src/rclcpp/any_executable.cpp
Line 34 in 97ed34a