-
Notifications
You must be signed in to change notification settings - Fork 21
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
Difference in behaviour of Future.find #11827
Comments
I don't even understand how the 2.12 version does return a result.
And |
2.12 has a different implementation. |
Aha, I don't know how I managed to not see that one. 2.12 has 2 implementations and we were calling the deprecated one.
then you see the same behavior as in 2.13. |
That was an interesting opportunity to review the well-reviewed SIP-14 improvements PR, and also to re-read the blog. I suspect the change is a result of "prefer transform/transformWith over onComplete" (not a direct quote). There's also a sentiment of "don't bloat the API" (direct quote). What's expected here is I seem to remember a stackoverflow question asking for it, too. I wonder if this means no one has used the new |
of interest to @viktorklang...? |
@SethTisue @som-snytt I think a Task-like construct would be the correct place to add a feature like this (since you want to cancel tasks, rather than Futures). |
The Scaladoc for |
Coming back to this, IMHO the former interpretation would be more reasonable if the parameter to |
this came up again at #12325. the 2.13 semantics are now established, I don't think we're free to change them at this point. (if this had been reported against a 2.13 prerelease, we could have had a different discussion, perhaps.) |
Just some thoughts regarding to the interpretation of "first". I assume we all started learning single threaded algorithms before multithreaded ones (where we have to consider the parallel universes too). At that time the "first in the Iterable" was the same as "first in time" and maybe this equivalence made these algorithms interesting. In case of multithreading the interpretation makes a difference and my gut tells me (and the task I was facing) that time is more interesting than the ordering. I'm not saying that the "find" should be rewritten but if there is no "first in time" algorithm then users will improvise. |
iiuc @viktorklang is arguing that "first in time" isn't worth doing unless you can also cancel the others, but I would need further convincing on that point. |
note that binary compatibility constraints forbid us from adding a new "first in time" method to the Scala 2 stdlib, but perhaps it could happen over at https://github.com/scala/scala-library-next |
That's a fine design principle to have, but And it's not at all clear from the docs that both methods have a different interpretation of "first". |
Hi, it looks like the behaviour of
Future.find
changed in scala 2.13 when one of the futures in the sequence passed to find never completes.I'm not completely sure if the behaviour is intentional, but it was surprising to me.
In scala 2.12.8 the result is
res0: Boolean = true
In scala 2.13.1 the result is
java.util.concurrent.TimeoutException: Future timed out after [5 seconds]
Reversing the sequence will result in
res0: Boolean = true
in both scala versions.The text was updated successfully, but these errors were encountered: