Add friendlier method of starting a Future

This commit is contained in:
Derek Williams 2011-02-28 11:47:39 -07:00
parent ac2462f080
commit 4bd00bc92f

View file

@ -138,6 +138,14 @@ object Futures {
}.map(_.result)
}
object Future {
def apply[T](body: => T, timeout: Long = Actor.TIMEOUT)(implicit dispatcher: MessageDispatcher): Future[T] = {
val f = new DefaultCompletableFuture[T](timeout)
dispatcher.dispatchFuture(FutureInvocation(f.asInstanceOf[CompletableFuture[Any]], () => body))
f
}
}
sealed trait Future[T] {
/**
* Blocks the current thread until the Future has been completed or the