Replies: 1 comment
-
One thing which I’ve done recently with Java’s CompletableFuture is have interfaces which separate the producer and consumer side of the CF interface, it is quite odd that in Java consumers are allowed to complete their future other then via cancelation. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We've been using the @future annotation and the corresponding type and API (FutureVar) quite a bit lately, and it's been good to really give it a work-out. The
@Future
annotation is FutureVar; there's a file that allows names to be automatically imported, and "FutureVar" is imported as "Future", so@Future
is how it gets mixed in to a variable:Generally, we put a stick in the ground with design, and then wait until we give it a real work-out before trying to improve the design. Now that's we've been using FutureVar "in anger", we have a pretty good idea of some improvements that are needed. There's some simple stuff, like getting rid of the createContinuation() method. But there are bigger things; for example, FutureVar is simply too (pardon the pun) generic. With conditional mix-ins, we can create FutureVar APIs that are tailored to various types, such as Boolean. You can see conditional mix-ins used extensively with Array, for example.
You could imagine constructs such as:
Perhaps, async short circuit logic like:
Some other possibilities:
Exceptions are still a bit tedious to handle, but it's not apparent that there are better approaches than the current handle() method. A void exception handler might be nice:
Depending on what other methods are introduced that could be chained, it might also be nice to have a simple, non-altering "wait for completion" method, like:
But there is also a use case for a "service has timed out, so now use the backup plan" method; perhaps something like:
I just wanted to capture some of these ideas that we've been discussing here, for future reference. None of this is critical path for the current project, but there are some definite "nice to haves" that we should be considering, for when we get around to opening up this patient.
Beta Was this translation helpful? Give feedback.
All reactions