Encouraged by other team members, I've re-factored my blocking, 
*Await#result* (returning type T) calls with *Future[T]*.

Here's an example for readers who aren't familiar:

scala> import scala.concurrent.{Future, Await}

import scala.concurrent.{Future, Await}


scala> import scala.concurrent.ExecutionContext.Implicits.global

import scala.concurrent.ExecutionContext.Implicits.global


scala> Future { 42 }

res1: scala.concurrent.Future[Int] = 
scala.concurrent.impl.Promise$DefaultPromise@34cd072c


scala> import scala.concurrent.duration._

import scala.concurrent.duration._


scala> Await.result(res1, 2.seconds)

res2: Int = 42


scala> Future ( 42 )

res3: scala.concurrent.Future[Int] = 
scala.concurrent.impl.Promise$DefaultPromise@333291e3


I believe that, reasoning about code using a Future, which provides `map` 
and `flatMap` (I'm not sure if the Functor and Monad Laws are upheld - but 
nevertheless) methods.


However, what's the downside of blocking with Await.result versus using 
Future? 


Also, what if I put the Await.result at the end of the world, i.e. in a web 
service's route?

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to