blob: 14f76f72da17e84956bbee00a7ea3552a0ecb84f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package moe.nea.notenoughupdates.util
import kotlin.time.Duration
import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource
@OptIn(ExperimentalTime::class)
class Timer {
private var mark: TimeSource.Monotonic.ValueTimeMark? = null
fun timePassed(): Duration {
return mark?.elapsedNow() ?: Duration.INFINITE
}
fun markNow() {
mark = TimeSource.Monotonic.markNow()
}
fun markFarPast() {
mark = null
}
}
|