From 2c9a813eb61c7b6fcb331c8b54233bd10450bbd7 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sat, 23 Apr 2011 11:53:51 -0600 Subject: [PATCH] Refactor Future.flow --- .../src/main/scala/akka/dispatch/Future.scala | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index f93696f925..fc8e8ecf3f 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -264,17 +264,8 @@ object Future { for (r <- fr; b <-fb) yield (r += b) }.map(_.result) - def flow[A](body: => A @cps[Future[Any]], timeout: Long = Actor.TIMEOUT): Future[A] = { - - val future = new DefaultCompletableFuture[A](timeout) - - reset(future completeWithResult body) onComplete { f => - val ex = f.exception - if (ex.isDefined) future.completeWithException(ex.get) - } - - future - } + def flow[A](body: => A @cps[Future[A]], timeout: Long = Actor.TIMEOUT): Future[A] = + reset(new DefaultCompletableFuture[A](timeout).completeWithResult(body)) } sealed trait Future[+T] {