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

Always trigger guard condition waitset #1923

Merged
merged 5 commits into from
Jun 2, 2022
Merged

Always trigger guard condition waitset #1923

merged 5 commits into from
Jun 2, 2022

Conversation

alsora
Copy link
Collaborator

@alsora alsora commented Apr 29, 2022

Ttrigger guard condition waitset regardless of whether a trigger callback is present
This should address #1917

Also minor cleanup at the class (remove unneded lock and better use of if-else)

Signed-off-by: Alberto Soragna alberto.soragna@gmail.com

…ack is present

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
@alsora
Copy link
Collaborator Author

alsora commented May 13, 2022

I restored the mutex to prevent race condition that could cause problems.

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.

lgtm with minor nit

rclcpp/src/rclcpp/guard_condition.cpp Outdated Show resolved Hide resolved
Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

Looks reasonable.

It seems like a test to avoid this regressing in the future would be good to have.

Also, if it's not already clear from the docstring what should happen in this corner case, it should be clarified there.

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
@alsora
Copy link
Collaborator Author

alsora commented May 17, 2022

Added unit-tests.

Running full CI

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@wjwwood
Copy link
Member

wjwwood commented May 17, 2022

This doc block should mention how it interacts with the "on trigger callback":

/// Notify the wait set waiting on this condition, if any, that the condition had been met.
/**
* This function is thread-safe, and may be called concurrently with waiting
* on this guard condition in a wait set.
*
* \throws rclcpp::exceptions::RCLError based exceptions when underlying
* rcl functions fail.
*/
RCLCPP_PUBLIC
void
trigger();

And, I guess we missed it, but we should have some documentation on the "on trigger callback" method as well (it currently has none):

RCLCPP_PUBLIC
void
set_on_trigger_callback(std::function<void(size_t)> callback);

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
@alsora
Copy link
Collaborator Author

alsora commented Jun 1, 2022

@wjwwood @fujitatomoya anything else to do here?

@fujitatomoya
Copy link
Collaborator

@alsora i am good to go! @wjwwood could you check your comments on #1923 (comment)?

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

lgtm

Sorry for not re-reviewing it. I don't get notifications for pushed commits, so a comment is helpful to bump a re-review.

@alsora alsora merged commit 790e529 into master Jun 2, 2022
@delete-merged-branch delete-merged-branch bot deleted the asoragna/rclcpp-1917 branch June 2, 2022 17:58
apojomovsky pushed a commit to apojomovsky/rclcpp that referenced this pull request May 29, 2024
* trigger guard condition waitset regardless of whether a trigger callback is present

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>

* restore mutex in guard_condition.cpp

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>

* remove whitespace

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>

* add unit-test

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>

* add documentation for trigger and set_on_trigger_callback

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants