Closed AaronLPS closed 8 months ago
that is why we are using std::shared_future
here?
or are you receiving the std::future_error
exception with this demo in your environment?
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);
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.