-
Notifications
You must be signed in to change notification settings - Fork 430
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 sure to wait for graph change events in test_node_graph. #1503
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
@clalancette I'm not sure I follow this bit -- or at least I find it counter-intuitive.
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 agree that it is counter-intuitive, though it is the way current
NodeGraph
API is setup.A call to node->get_graph_event ends up calling node_graph->get_graph_event. There, a new shared pointer to
rclcpp::Event
is created, a weak reference to thatEvent
is stored, thegraph_users_count_
is incremented, and the shared pointer is returned. However, there is no explicit decrement ofgraph_users_count_
. Instead, whennotify_graph_change
is called, it loops through the weak pointers, attempting to lock them. If it finds one that it cannot lock anymore (because it has been destroyed), then it removes that weak pointer from the list and recalculates the size ofgraph_users_count
. That way you'll get the "correct" number of graph users when you later callcount_graph_users
.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 see. It's out of scope for this PR, but it'd be nice to have a way to explicitly drop the event instead of doing this.
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 also seems like an abuse of this function to me. If you need to prune old events then maybe we should have a function for that, but why does that matter?
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.
To be specific, I confused why clearing the old events is important.
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.
Mostly because of this check:
rclcpp/rclcpp/test/rclcpp/node_interfaces/test_node_graph.cpp
Line 94 in b9ef1fe
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 don't even understand what that check is doing? Maybe just getting coverage on that function? The value it returns isn't really important I think.
I mean if we ever added something to the node that happen to use the graph events, this would break because there would be more users. I think that change could just be changed to >= 1, if needed?
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.
That's true, we could do that.
Here's what I'm going to do. To take advantage of the CI that already successfully completed, I'm going to merge this PR as-is. That fixes one of our current problems in ros2/rmw#293 . I'll do an immediate follow-up to change that fragile
count_graph_users
test and remove thenotify_graph_change
, which should satisfy @wjwwood 's concerns.