From 4c9ffd2a25d06cc406ff15867d1c03391bb3f620 Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Fri, 27 Sep 2024 17:51:45 +0300 Subject: [PATCH] Replace a usage of deprecated getTimeNanos() in K/N The function was deprecated with warning in Kotlin 1.9. In Kotlin 2.1 the deprecation level will be raised to error. See KT-71628 --- kotlinx-coroutines-core/native/src/EventLoop.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kotlinx-coroutines-core/native/src/EventLoop.kt b/kotlinx-coroutines-core/native/src/EventLoop.kt index e457842e34..4265f6094f 100644 --- a/kotlinx-coroutines-core/native/src/EventLoop.kt +++ b/kotlinx-coroutines-core/native/src/EventLoop.kt @@ -4,7 +4,7 @@ package kotlinx.coroutines import kotlin.coroutines.* import kotlin.native.concurrent.* -import kotlin.system.* +import kotlin.time.* internal actual abstract class EventLoopImplPlatform : EventLoop() { @@ -26,5 +26,6 @@ internal class EventLoopImpl: EventLoopImplBase() { internal actual fun createEventLoop(): EventLoop = EventLoopImpl() -@Suppress("DEPRECATION") -internal actual fun nanoTime(): Long = getTimeNanos() +private val startingPoint = TimeSource.Monotonic.markNow() + +internal actual fun nanoTime(): Long = (TimeSource.Monotonic.markNow() - startingPoint).inWholeNanoseconds