Real use cases of scala -async?

Today I studied the implementation of something really basic, using scala -async , namely the repetition loop for a function that might fail.

First, I could not use await() in a try/catch ; well, this was expected, I think; so I converted the function to return Future[Try[T]] instead, which, of course, is redundant under normal circumstances, since Future[T] already contains some exceptions, but allowed me to call isSuccess on the return value instead of try/catch .

Then I tried to implement loop logic. nested recursive iter() out of the question (again, as expected), because await() cannot be used in nested functions. Initially, with the good old while I led to success, since I was actually experimenting with the Future[Try[Unit]] function, so I did not like the return value; however, as soon as I changed to Future[Try[Int]] and therefore started taking care of the return value, I needed to save Try[Int] , which I selected from the await() call, to not only check if isSuccess but also return its contents. However, as soon as I tried val ret = await(...) , I received an error message:

await must not be used under a by-name argument

So, my question is, given (at least) these 3 limitations, the last of which, I would say, limits, at least, apparently, the scala rendering async, which is useless for any real life code, the selected examples are like await(x) + await(y) , what are the currently known useful real-life applications of this library?

+7
asynchronous scala concurrency future
source share

No one has answered this question yet.

See related questions:

957
How and when to use asynchronous and standby
790
Is the Scala 2.8 collection library "the longest suicide record in history"?
676
Scala vs Groovy vs Clojure
515
Good use case for Akka.
492
What are the benefits of underscoring in Scala?
74
Why should not all functions be asynchronous by default?
49
Why should I use std :: async?
nine
How to use> => in Scala?
one
Catch Dangling or Unused Futures in Scala
0
Need Help Understanding Scala Frames with Scrimage Image Pack

All Articles