Skip to content

Instantly share code, notes, and snippets.

@meetumaltiar
meetumaltiar / gist:4562364
Created January 18, 2013 04:36
for expression on futures
import akka.dispatch.Future
import akka.actor.ActorSystem
object SumApplicationWithFutures extends App {
implicit val system = ActorSystem("future")
val startTime = System.currentTimeMillis
val future1 = Future(timeTakingIdentityFunction(1))
val future2 = Future(timeTakingIdentityFunction(2))
val future3 = Future(timeTakingIdentityFunction(3))
@meetumaltiar
meetumaltiar / gist:4561789
Created January 18, 2013 02:14
Composing Futures
import akka.dispatch.Future
import akka.actor.ActorSystem
object FutureMonadic extends App {
implicit val system = ActorSystem("future")
val startTime = System.currentTimeMillis
// we construct List[Future[Int]]
val futureList = List(1, 2, 3) map { case number => Future(timeTakingIdentityFunction(number)) }
val future = Future.sequence(futureList)