Skip to content

Commit

Permalink
Fixed race in Future.await, and minor changes to Future.result and Fu…
Browse files Browse the repository at this point in the history
…ture.exception
  • Loading branch information
derekjw committed Aug 6, 2011
1 parent 8a1d316 commit bc1f756
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions akka-actor/src/main/scala/akka/dispatch/Future.scala
Original file line number Diff line number Diff line change
Expand Up @@ -407,16 +407,16 @@ sealed trait Future[+T] extends japi.Future[T] {
* Returns the successful result of this Future if it exists.
*/
final def result: Option[T] = value match {
case Some(r) r.right.toOption
case _ None
case Some(Right(r)) Some(r)
case _ None
}

/**
* Returns the contained exception of this Future if it exists.
*/
final def exception: Option[Throwable] = value match {
case Some(r) r.left.toOption
case _ None
case Some(Left(e)) Some(e)
case _ None
}

/**
Expand Down Expand Up @@ -740,7 +740,7 @@ class DefaultPromise[T](val timeout: Timeout)(implicit val dispatcher: MessageDi
val ms = NANOS.toMillis(waitTimeNanos)
val ns = (waitTimeNanos % 1000000l).toInt //As per object.wait spec
val start = currentTimeInNanos
try { ref.synchronized { ref.wait(ms, ns) } } catch { case e: InterruptedException }
try { ref.synchronized { if (value.isEmpty) ref.wait(ms, ns) } } catch { case e: InterruptedException }

awaitUnsafe(waitTimeNanos - (currentTimeInNanos - start))
} else {
Expand Down

0 comments on commit bc1f756

Please sign in to comment.