Skip to content

Conversation

@ivanpauno
Copy link
Collaborator

Don't use spin() in RCLFuture.get().
The problem with that is that you cannot currently call spin() more than once, so that model is really limited.

This uses a model more similar to the one in rclcpp.
You can block on a future while spinning in another thread, or use Executor.spinUntilComplete().

That model is still somewhat limited, but a bit better.

Note: this may break prexisting code that were calling Future.get() without spinning.

Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
@ivanpauno ivanpauno added the enhancement New feature or request label Jul 16, 2021
@ivanpauno ivanpauno requested a review from jacobperron July 16, 2021 20:02
@ivanpauno ivanpauno self-assigned this Jul 16, 2021
@ivanpauno
Copy link
Collaborator Author

I think we could actually use https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html instead of our own implementation of a Future.
Though that class was added in java 8, it's available on Android https://developer.android.com/reference/java/util/concurrent/CompletableFuture (since API 24).

Copy link

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

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

LGTM, one suggestion.

I guess we should update the examples repo too: https://github.com/osrf/ros2_java_examples

Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
@ivanpauno ivanpauno merged commit f2eeac7 into galactic-devel Jul 29, 2021
@ivanpauno ivanpauno deleted the ivanpauno/refactor-future branch July 29, 2021 16:23
jacobperron pushed a commit to ros2-java/ros2_java that referenced this pull request May 17, 2022
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants