Skip to content

Commit 0dc50e9

Browse files
authored
Rename TimeSource to AbstractTimeSource due to KT-42625 (#2696)
* It is the second TimeSource in our codebase * Also make it abstract to let CHA kick in Fixes #2691
1 parent 9d2a756 commit 0dc50e9

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

kotlinx-coroutines-core/jvm/src/TimeSource.kt renamed to kotlinx-coroutines-core/jvm/src/AbstractTimeSource.kt

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ package kotlinx.coroutines
1010
import java.util.concurrent.locks.*
1111
import kotlin.internal.InlineOnly
1212

13-
internal interface TimeSource {
14-
fun currentTimeMillis(): Long
15-
fun nanoTime(): Long
16-
fun wrapTask(block: Runnable): Runnable
17-
fun trackTask()
18-
fun unTrackTask()
19-
fun registerTimeLoopThread()
20-
fun unregisterTimeLoopThread()
21-
fun parkNanos(blocker: Any, nanos: Long) // should return immediately when nanos <= 0
22-
fun unpark(thread: Thread)
13+
internal abstract class AbstractTimeSource {
14+
abstract fun currentTimeMillis(): Long
15+
abstract fun nanoTime(): Long
16+
abstract fun wrapTask(block: Runnable): Runnable
17+
abstract fun trackTask()
18+
abstract fun unTrackTask()
19+
abstract fun registerTimeLoopThread()
20+
abstract fun unregisterTimeLoopThread()
21+
abstract fun parkNanos(blocker: Any, nanos: Long) // should return immediately when nanos <= 0
22+
abstract fun unpark(thread: Thread)
2323
}
2424

2525
// For tests only
2626
// @JvmField: Don't use JvmField here to enable R8 optimizations via "assumenosideeffects"
27-
internal var timeSource: TimeSource? = null
27+
internal var timeSource: AbstractTimeSource? = null
2828

2929
@InlineOnly
3030
internal inline fun currentTimeMillis(): Long =

kotlinx-coroutines-core/jvm/test/VirtualTimeSource.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.coroutines
@@ -42,7 +42,7 @@ private const val REAL_PARK_NANOS = 10_000_000L // 10 ms -- park for a little to
4242
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
4343
internal class VirtualTimeSource(
4444
private val log: PrintStream?
45-
) : TimeSource {
45+
) : AbstractTimeSource() {
4646
private val mainThread: Thread = Thread.currentThread()
4747
private var checkpointNanos: Long = System.nanoTime()
4848

0 commit comments

Comments
 (0)