From 7a4b2c45a9926de59754b1d7219159656eea6e6d Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Wed, 9 Nov 2022 17:25:59 +0000 Subject: refactor: Use InstantSource as time source This change updates the modules of OpenDC to always accept the `InstantSource` interface as source of time. Previously we used `java.time.Clock`, but this class is bound to a time zone which does not make sense for our use-cases. Since `java.time.Clock` implements `java.time.InstantSource`, it can be used in places that require an `InstantSource` as parameter. Conversion from `InstantSource` to `Clock` is also possible by invoking `InstantSource#withZone`. --- opendc-common/src/main/kotlin/org/opendc/common/util/Pacer.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'opendc-common/src/main/kotlin/org/opendc/common/util/Pacer.kt') diff --git a/opendc-common/src/main/kotlin/org/opendc/common/util/Pacer.kt b/opendc-common/src/main/kotlin/org/opendc/common/util/Pacer.kt index edf607d2..b6141db1 100644 --- a/opendc-common/src/main/kotlin/org/opendc/common/util/Pacer.kt +++ b/opendc-common/src/main/kotlin/org/opendc/common/util/Pacer.kt @@ -26,7 +26,7 @@ import kotlinx.coroutines.Delay import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.InternalCoroutinesApi import java.lang.Runnable -import java.time.Clock +import java.time.InstantSource import kotlin.coroutines.ContinuationInterceptor import kotlin.coroutines.CoroutineContext @@ -40,7 +40,7 @@ import kotlin.coroutines.CoroutineContext */ public class Pacer( private val context: CoroutineContext, - private val clock: Clock, + private val clock: InstantSource, private val quantum: Long, private val process: (Long) -> Unit ) { -- cgit v1.2.3