[GitHub] [spark] advancedxy commented on a change in pull request #26058: [SPARK-10614][core] Add monotonic time to Clock interface.

2019-10-08 Thread GitBox
advancedxy commented on a change in pull request #26058: [SPARK-10614][core] 
Add monotonic time to Clock interface.
URL: https://github.com/apache/spark/pull/26058#discussion_r332817520
 
 

 ##
 File path: core/src/main/scala/org/apache/spark/util/Clock.scala
 ##
 @@ -21,7 +21,14 @@ package org.apache.spark.util
  * An interface to represent clocks, so that they can be mocked out in unit 
tests.
  */
 private[spark] trait Clock {
+  /** @return Current system time, in ms. */
   def getTimeMillis(): Long
+  /** @return Current value of monotonic time source, in ns. */
+  def nanoTime(): Long
+  /**
 
 Review comment:
   Nit: add blank line between methods?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] advancedxy commented on a change in pull request #26058: [SPARK-10614][core] Add monotonic time to Clock interface.

2019-10-08 Thread GitBox
advancedxy commented on a change in pull request #26058: [SPARK-10614][core] 
Add monotonic time to Clock interface.
URL: https://github.com/apache/spark/pull/26058#discussion_r332817884
 
 

 ##
 File path: core/src/main/scala/org/apache/spark/util/Clock.scala
 ##
 @@ -36,19 +43,23 @@ private[spark] class SystemClock extends Clock {
* @return the same time (milliseconds since the epoch)
* as is reported by `System.currentTimeMillis()`
*/
-  def getTimeMillis(): Long = System.currentTimeMillis()
+  override def getTimeMillis(): Long = System.currentTimeMillis()
+
+  /**
+   * @return value reported by `System.nanoTime()`.
+   */
+  override def nanoTime(): Long = System.nanoTime()
 
   /**
* @param targetTime block until the current time is at least this value
* @return current system time when wait has completed
*/
-  def waitTillTime(targetTime: Long): Long = {
-var currentTime = 0L
-currentTime = System.currentTimeMillis()
+  override def waitTillTime(targetTime: Long): Long = {
+var currentTime = System.currentTimeMillis()
 
 var waitTime = targetTime - currentTime
 if (waitTime <= 0) {
-  return currentTime
+  return getTimeMillis()
 
 Review comment:
   Why not just `return currentTime`?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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