Fixing #467
This commit is contained in:
parent
93d23854b6
commit
7eb75cda88
1 changed files with 13 additions and 11 deletions
|
|
@ -5,9 +5,10 @@
|
|||
package se.scalablesolutions.akka.dispatch
|
||||
|
||||
import se.scalablesolutions.akka.AkkaException
|
||||
|
||||
import se.scalablesolutions.akka.actor.Actor.spawn
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import java.util.concurrent.TimeUnit
|
||||
import se.scalablesolutions.akka.routing.Dispatcher
|
||||
|
||||
class FutureTimeoutException(message: String) extends AkkaException(message)
|
||||
|
||||
|
|
@ -20,18 +21,19 @@ object Futures {
|
|||
* ... // do stuff
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
def future[T](timeout: Long)(body: => T): Future[T] = {
|
||||
val promise = new DefaultCompletableFuture[T](timeout)
|
||||
*/
|
||||
def future[T](timeout: Long,
|
||||
dispatcher: MessageDispatcher = Dispatchers.defaultGlobalDispatcher)
|
||||
(body: => T): Future[T] = {
|
||||
val f = new DefaultCompletableFuture[T](timeout)
|
||||
|
||||
try {
|
||||
promise completeWithResult body
|
||||
} catch {
|
||||
case e => promise completeWithException e
|
||||
}
|
||||
promise
|
||||
spawn({
|
||||
try { f completeWithResult body }
|
||||
catch { case e => f completeWithException e}
|
||||
})(dispatcher)
|
||||
|
||||
f
|
||||
}
|
||||
*/
|
||||
|
||||
def awaitAll(futures: List[Future[_]]): Unit = futures.foreach(_.await)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue