The philosophy behind Akka/Scala Future is that when ever we find a blocking piece of code such as IO call , network call etc we have to wrap it up inside a future and asynchronously get the result after some point of time. But, the blocking piece of code that was blocking the main thread earlier is now blocking in the separate thread that Future is backed by. then what did Akka/Scala Future buy us.
val blockingCallResult: Result = block() //blocks the thread of execution.
now let's use Akka/Scala future and wrap the blocking call with Future
val future = Future[Result] {
val blockingCallResult: Result = block() //also blocks on some thread in thread pool
blockingCallResult
}
How are we getting benefited by using the future.
FutureAPI? - mikołak