From 95a7fb020329daf86acb90694d46c8a0fcf5c77a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 9 Apr 2024 16:50:42 +0700 Subject: [PATCH] Remove time source since it is very usage specific --- gradle.properties | 2 +- .../ru/dbotthepony/kommons/util/TimeSource.kt | 53 ------------------- 2 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/kommons/util/TimeSource.kt diff --git a/gradle.properties b/gradle.properties index 926924e..750524d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ kotlin.code.style=official specifyKotlinAsDependency=false projectGroup=ru.dbotthepony.kommons -projectVersion=2.13.1 +projectVersion=2.14.0 guavaDepVersion=33.0.0 gsonDepVersion=2.8.9 diff --git a/src/main/kotlin/ru/dbotthepony/kommons/util/TimeSource.kt b/src/main/kotlin/ru/dbotthepony/kommons/util/TimeSource.kt deleted file mode 100644 index 71ba6a8..0000000 --- a/src/main/kotlin/ru/dbotthepony/kommons/util/TimeSource.kt +++ /dev/null @@ -1,53 +0,0 @@ -package ru.dbotthepony.kommons.util - -interface ITimeSource { - val nanos: Long - val micros: Long get() = nanos / 1_000L - val millis: Long get() = nanos / 1_000_000L - val seconds: Double get() = (nanos / 1_000L) / 1_000_000.0 -} - -class JVMTimeSource : ITimeSource { - private val origin = System.nanoTime() - - override val nanos: Long - get() = System.nanoTime() - origin - - companion object { - @JvmField - val INSTANCE = JVMTimeSource() - } -} - -class ArtificialTimeSource(nanos: Long = 0L) : ITimeSource { - override var nanos: Long = nanos - private set - - fun advance(nanos: Long) { - this.nanos += nanos - } -} - -class PausableTimeSource(private val parent: ITimeSource) : ITimeSource { - override val nanos: Long get() { - if (isPaused) { - return pausedSince - skipped - } else { - return parent.nanos - skipped - } - } - - private var isPaused = false - private var pausedSince = 0L - private var skipped = 0L - - fun pause() { - if (!isPaused) { - isPaused = true - pausedSince = parent.nanos - } else { - isPaused = false - skipped += parent.nanos - pausedSince - } - } -}