1 package leakcanary
2
3 /**
4 * An interface to abstract the SystemClock.uptimeMillis() Android API in non Android artifacts.
5 *
6 * This is a functional interface with which you can create a [Clock] from a lambda.
7 */
interfacenull8 fun interface Clock {
9 /**
10 * On Android VMs, this should return android.os.SystemClock.uptimeMillis().
11 */
12 fun uptimeMillis(): Long
13
14 companion object {
15 /**
16 * Utility function to create a [Clock] from the passed in [block] lambda
17 * instead of using the anonymous `object : Clock` syntax.
18 *
19 * Usage:
20 *
21 * ```kotlin
22 * val clock = Clock {
23 *
24 * }
25 * ```
26 */
27 inline operator fun invoke(crossinline block: () -> Long): Clock =
28 Clock { block() }
29 }
30 }
31