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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]