Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9264#discussion_r44864658
  
    --- Diff: core/src/main/scala/org/apache/spark/FutureAction.scala ---
    @@ -116,57 +119,27 @@ class SimpleFutureAction[T] private[spark](jobWaiter: 
JobWaiter[_], resultFunc:
       }
     
       override def ready(atMost: Duration)(implicit permit: CanAwait): 
SimpleFutureAction.this.type = {
    -    if (!atMost.isFinite()) {
    -      awaitResult()
    -    } else jobWaiter.synchronized {
    -      val finishTime = System.currentTimeMillis() + atMost.toMillis
    -      while (!isCompleted) {
    -        val time = System.currentTimeMillis()
    -        if (time >= finishTime) {
    -          throw new TimeoutException
    -        } else {
    -          jobWaiter.wait(finishTime - time)
    -        }
    -      }
    -    }
    +    jobWaiter.completionFuture.ready(atMost)
         this
       }
     
       @throws(classOf[Exception])
       override def result(atMost: Duration)(implicit permit: CanAwait): T = {
    -    ready(atMost)(permit)
    -    awaitResult() match {
    -      case scala.util.Success(res) => res
    -      case scala.util.Failure(e) => throw e
    -    }
    +    jobWaiter.completionFuture.ready(atMost)
    +    assert(value.isDefined, "Future has not completed properly")
    +    value.get.get
       }
     
       override def onComplete[U](func: (Try[T]) => U)(implicit executor: 
ExecutionContext) {
    -    executor.execute(new Runnable {
    -      override def run() {
    -        func(awaitResult())
    -      }
    -    })
    +    jobWaiter.completionFuture onComplete {_ => func(value.get)}
       }
     
       override def isCompleted: Boolean = jobWaiter.jobFinished
     
       override def isCancelled: Boolean = _cancelled
     
    -  override def value: Option[Try[T]] = {
    -    if (jobWaiter.jobFinished) {
    -      Some(awaitResult())
    -    } else {
    -      None
    -    }
    -  }
    -
    -  private def awaitResult(): Try[T] = {
    -    jobWaiter.awaitResult() match {
    -      case JobSucceeded => scala.util.Success(resultFunc)
    -      case JobFailed(e: Exception) => scala.util.Failure(e)
    -    }
    -  }
    +  override def value: Option[Try[T]] =
    +    jobWaiter.completionFuture.value.map {res => res.map {_ => resultFunc}}
    --- End diff --
    
    I could be wrong about this one too -- is it the `map(resultFunc)` that 
doesn't work? keep it if so though this doesn't need braces. The other change 
should work.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to