Add friendlier method of starting a Future
This commit is contained in:
parent
ac2462f080
commit
4bd00bc92f
1 changed files with 8 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue