Skip to content

Wrapping future #44

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

Closed
jroper opened this issue Jun 23, 2015 · 2 comments
Closed

Wrapping future #44

jroper opened this issue Jun 23, 2015 · 2 comments
Assignees
Milestone

Comments

@jroper
Copy link

jroper commented Jun 23, 2015

I'm wondering why FutureConverters.toJava creates a new CompletableFuture, rather than simply wrapping the Future with an implementation of CompletionStage that delegates to Future? Doing this would make conversion a little more efficient, and would mean conversions back and forth could be optimised so a conversion from a previously converted CompletionStage to Future would simply unwrap the Future.

The latter especially will be useful in Play, since we want to allow both Java and Scala code to intercept requests, and mixing these interceptors will potentially mean lots of conversions back and forth between the types. If it's just a simple wrapping/unwrapping, then we don't need to worry about the cost associated with it, otherwise we may end up with long chains of Futures and CompletionStages that add nothing to the actual value except overhead.

@retronym
Copy link
Member

/cc @rkuhn, who contributed this part of the library.

@rkuhn
Copy link
Contributor

rkuhn commented Jun 23, 2015

The current approach was meant to be minimal, but we might have to bite the bullet. Writing a fully optimized version will be very painful, though.

retronym added a commit to retronym/scala-java8-compat that referenced this issue Jul 28, 2015
Makes `toJava.toScala` and `toScala.toJava` a wrap-and-unwrap
operation, rather than a wrap-and-rewrap.

This won't be possible if we merge scala#46, which speaks in favour
of reverting the change that finalized `DefaultPromise` in Scala
2.12.x.

This patch does not attempt to "wrap the Future with an implementation
of CompletionStage that delegates to Future", as Jame's proposed in
issue scala#44, which seems tricky or at least tedious to implement.
@retronym retronym added this to the 0.5.0 milestone Jul 28, 2015
@retronym retronym self-assigned this Jul 28, 2015
@retronym retronym modified the milestones: 0.5.0, 0.6.0 Aug 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants