Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress a usage of deprecated getTimeNanos() in K/N #4238

Open
wants to merge 1 commit into
base: kotlin-community/k2/dev
Choose a base branch
from

Conversation

qurbonzoda
Copy link
Contributor

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

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
@@ -26,5 +26,5 @@ internal class EventLoopImpl: EventLoopImplBase() {

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

@Suppress("DEPRECATION")
@Suppress("DEPRECATION_ERROR")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change can be merged to develop if we suppress both DEPRECATION and DEPRECATION_ERROR.
But, it would seem weird.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace it with the proposed replacement instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also underscores the need to refactor the usages of nanoTime() to use the Duration API instead. Having the kotlinx-datetime Clock and Instant in stdlib would simplify this migration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace it with the proposed replacement instead?

There is not direct replacement for the getTime currently.

Copy link
Contributor Author

@qurbonzoda qurbonzoda Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense to leave getTimeX deprecated with warning until a more direct replacement is introduced, though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither Clock nor Instant would be monotonic, though.

Maybe make the actualization on more granular groups of targets (linux, macos, mingw, androidNative) and invoke OS-level APIs to get the monotonic nano time. They're all just one- or two-liners.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants