From 9749b8c9e9f286f22e58dc7a7fe0e610d9293be7 Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Tue, 8 Oct 2024 11:48:00 +0300 Subject: [PATCH] Replace a usage of deprecated getTimeNanos() in K/N (#4238) 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