Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Await.result should work #186
import concurrent.duration._ Await.result(Future(1), 10 seconds)
This results in
It should probably just be an alias for
It's be kind of weird to just ignore the duration and basically timeout immediately if the
I'll use my right as author to veto here, and say: no.
Sure, it's weird to have things be blocking, but...
Allowing people to use "blocking" internally allows some very elegant re-use. In particular, it allows you to re-use the same code for synchronous and asynchronous algorithms, just by swapping out the
That lets you cover both synchronous (returns
On the other hand, if we insist that we shan't use
I don't feel super strongly since I just wrote my own wrapper for the time being. I do think that JS/JVM Sync/Async code re-use is valuable. On the other hand, taking
I'll leave it to you to decide and close this issue =)
I see how this can be useful for some functions that are written in async style. However, it is a rather unsafe thing to do.
Consider what should happen, when you call
My suggestion is to use Scala.async for the cases where you want to write procedural style:
will get rewritten (by macro) into something complicated, roughly equivalent to:
But yes, the bottom line is: If you are in async regime and you don't have threads, there is no going back.