Suggest duration static factories instead of number extension properties
Introduce Duration companion functions to convert numbers to Duration. Deprecate number extension properties and propose to use these new functions instead.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ internal class HrTimeSource(val process: Process) : TimeSource {
|
||||
override fun markNow(): TimeMark = object : TimeMark() {
|
||||
val startedAt = process.hrtime()
|
||||
override fun elapsedNow(): Duration =
|
||||
process.hrtime(startedAt).let { (seconds, nanos) -> seconds.seconds + nanos.nanoseconds }
|
||||
process.hrtime(startedAt).let { (seconds, nanos) -> Duration.seconds(seconds) + Duration.nanoseconds(nanos) }
|
||||
}
|
||||
|
||||
override fun toString(): String = "TimeSource(process.hrtime())"
|
||||
|
||||
Reference in New Issue
Block a user