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

Exception in get_state: std::future_error: No associated state #662

Closed
AaronLPS opened this issue Dec 18, 2023 · 2 comments
Closed

Exception in get_state: std::future_error: No associated state #662

AaronLPS opened this issue Dec 18, 2023 · 2 comments

Comments

@AaronLPS
Copy link

https://github.com/ros2/demos/blob/69aa0e4d8662b7bd06138462cc328415b3198263/lifecycle/src/lifecycle_service_client.cpp#L124C25-L124C38

The std::future::get() function can only be called once as it will invalidate the std::future after it's called. In this code, future_result.get() is called multiple times.

@fujitatomoya
Copy link
Collaborator

that is why we are using std::shared_future here?

auto future_result = client_get_state_->async_send_request(request).future.share();

or are you receiving the std::future_error exception with this demo in your environment?

@AaronLPS
Copy link
Author

std::shared_future solves the issue. I was looking at the outdated demo version in Foxy branch, which uses auto future_result = client_get_state->async_send_request(request);

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

No branches or pull requests

2 participants