Skip to content

Commit 9749b8c

Browse files
author
Abduqodiri Qurbonzoda
authored
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
1 parent 1c840d6 commit 9749b8c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: kotlinx-coroutines-core/native/src/EventLoop.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package kotlinx.coroutines
44

55
import kotlin.coroutines.*
66
import kotlin.native.concurrent.*
7-
import kotlin.system.*
7+
import kotlin.time.*
88

99
internal actual abstract class EventLoopImplPlatform : EventLoop() {
1010

@@ -26,5 +26,6 @@ internal class EventLoopImpl: EventLoopImplBase() {
2626

2727
internal actual fun createEventLoop(): EventLoop = EventLoopImpl()
2828

29-
@Suppress("DEPRECATION")
30-
internal actual fun nanoTime(): Long = getTimeNanos()
29+
private val startingPoint = TimeSource.Monotonic.markNow()
30+
31+
internal actual fun nanoTime(): Long = (TimeSource.Monotonic.markNow() - startingPoint).inWholeNanoseconds

0 commit comments

Comments
 (0)