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

Broken promise #47

Merged
merged 3 commits into from
Jun 25, 2015
Merged

Broken promise #47

merged 3 commits into from
Jun 25, 2015

Conversation

esteve
Copy link
Member

@esteve esteve commented Jun 23, 2015

This PR makes sure that promises are not destroyed too early, adds more cases to the list_parameters verb and fixes the parameters service to listen on the appropriate topic.

Fixes #44

@esteve esteve added the in progress Actively being worked on (Kanban column) label Jun 23, 2015
if (kv.first.find(prefix + ".") == 0) {
if (kv.first == prefix) {
return true;
} else if (kv.first.find(prefix + ".") == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Looks like there are two spaces between else and if, is that intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't run uncrustify yet, will do in a moment.

@esteve
Copy link
Member Author

esteve commented Jun 23, 2015

Don't review yet.

}

promise_result->set_value(parameter_variants);
get_parameters_promises_.erase(promise_result);
Copy link
Member

Choose a reason for hiding this comment

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

Can you prefix this with this->? I had trouble matching the use of this in the lambda to a specific line.

Copy link
Member

Choose a reason for hiding this comment

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

Same thing in a few places below.

@wjwwood
Copy link
Member

wjwwood commented Jun 23, 2015

Oh, sorry, I just assumed.

It actually looks good to me, other than the minor style comments.

@esteve
Copy link
Member Author

esteve commented Jun 23, 2015

@esteve
Copy link
Member Author

esteve commented Jun 23, 2015

@wjwwood no worries! :-) I noticed I hadn't run uncrustify before submitting the PR.

@esteve
Copy link
Member Author

esteve commented Jun 24, 2015

Please review.

if (std::string::npos != last_separator) {
std::string prefix = kv.first.substr(0, last_separator);
if (std::find(result.prefixes.cbegin(), result.prefixes.cend(),
prefix) == result.prefixes.cend())
Copy link
Member

Choose a reason for hiding this comment

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

I found reading this line pretty difficult due to the wrapping within the find call. Wrapping after the comparison operator == helped me to parse the line.

Copy link
Member

Choose a reason for hiding this comment

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

I also had trouble with that line, but I wasn't sure what to suggest at the time. I think that this is only slightly more readable:

        if (std::find(result.prefixes.cbegin(), result.prefixes.cend(), prefix) ==
          result.prefixes.cend())
        {
          /* stuff... */
        }

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.


auto request = std::make_shared<rcl_interfaces::srv::GetParameters::Request>();
request->names = names;

auto self = shared_from_this();
Copy link
Member

Choose a reason for hiding this comment

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

This will only work if the instance is already owned by another shared_ptr right? Do we make that guarantee?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm reworking this, I'll change switch the sets to shared pointers and just pass them down to the lambda.

Copy link
Member Author

Choose a reason for hiding this comment

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

Forget what I said, this won't work.

@esteve
Copy link
Member Author

esteve commented Jun 25, 2015

@tfoote
Copy link
Contributor

tfoote commented Jun 25, 2015

+1

@dirk-thomas
Copy link
Member

+1 (please squash before merge)

@esteve
Copy link
Member Author

esteve commented Jun 25, 2015

I made a few more changes to avoid storing the promises in the AsyncParametersClient instance and to prevent std::shared_future instances from being destroyed prematurely.

@jacquelinekay
Copy link
Contributor

Waiting on the next Linux Jenkins results before I approve.

@esteve
Copy link
Member Author

esteve commented Jun 25, 2015

@tfoote
Copy link
Contributor

tfoote commented Jun 25, 2015

Much simpler +1.

PS @wjwwood now has the new dedicated buildfarm running for ROS 2.0 The job has the same output here: http://ci.ros2.org/job/ros2_batch_ci_linux/8/
http://ci.ros2.org/job/ros2_batch_ci_linux/9 has the fix for ament/ament_lint#24

@wjwwood
Copy link
Member

wjwwood commented Jun 25, 2015

+1

@esteve
Copy link
Member Author

esteve commented Jun 25, 2015

Rebased against master and squashed the last changes. This builds fine, @jacquelinekay could you give a final review on this? Thanks!

@jacquelinekay
Copy link
Contributor

+1. looks good to me. I haven't followed the evolution of the issue/the solution and I don't have a lot of experience using std::promise and std::future, so I learned a bit from reviewing this.

@esteve
Copy link
Member Author

esteve commented Jun 25, 2015

Thanks everybody for going through this long PR

esteve added a commit that referenced this pull request Jun 25, 2015
@esteve esteve merged commit 8119064 into master Jun 25, 2015
@esteve esteve removed the in progress Actively being worked on (Kanban column) label Jun 25, 2015
@esteve esteve deleted the broken-promise branch June 25, 2015 22:55
mauropasse pushed a commit to mauropasse/rclcpp that referenced this pull request May 28, 2021
DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this pull request Aug 5, 2022
* ros2GH-101 Add converter interface

* ros2GH-102 Create format converter factory

* ros2GH-103 Write documentation for converter plugin authors

* ros2GH-16 Adjust rosbag2 message type

* ros2GH-16 Change name of converter interface to include "serialization"

- Easier to differentiate between storage format (e.g. sqlite)
  and serialization format (e.g. cdr)
- Closer to naming in ros middleware

* ros2GH-16 Improve plugin development documentation

- Also adapt to name changes

* ros2GH-16 Fix naming of SerializationFormatConverterFactory
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.

Fix 'broken promise' error in parameter client
5 participants