Bring back Duration construction extensions KT-46229

Return the extension properties for constructing Duration from numbers,
but this time place them in Duration.Companion rather than on top-level.

- provide the new set of construction extension properties
  in companion of Duration
- leave top-level extension properties experimental,
  increase their deprecation level to ERROR,
  propose the extension properties in companion instead.
- leave Duration companion static factory functions experimental,
  deprecate them and propose the extension properties in companion instead.
This commit is contained in:
Ilya Gorbunov
2021-09-19 04:50:41 +03:00
committed by Space
parent 96611de344
commit 21a9198fff
10 changed files with 818 additions and 288 deletions
@@ -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) -> Duration.seconds(seconds) + Duration.nanoseconds(nanos) }
process.hrtime(startedAt).let { (seconds, nanos) -> seconds.toDuration(DurationUnit.SECONDS) + nanos.toDuration(DurationUnit.NANOSECONDS) }
}
override fun toString(): String = "TimeSource(process.hrtime())"