Skip to content

Commit af9a201

Browse files
committed
Introduce DebugProbes.isInstalled method
1 parent 1b378ba commit af9a201

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

binary-compatibility-validator/reference-public-api/kotlinx-coroutines-debug.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public final class kotlinx/coroutines/debug/DebugProbes {
1515
public final fun dumpCoroutinesInfo ()Ljava/util/List;
1616
public final fun getSanitizeStackTraces ()Z
1717
public final fun install ()V
18+
public final fun isInstalled ()Z
1819
public final fun jobToString (Lkotlinx/coroutines/Job;)Ljava/lang/String;
1920
public final fun printJob (Lkotlinx/coroutines/Job;Ljava/io/PrintStream;)V
2021
public static synthetic fun printJob$default (Lkotlinx/coroutines/debug/DebugProbes;Lkotlinx/coroutines/Job;Ljava/io/PrintStream;ILjava/lang/Object;)V

kotlinx-coroutines-debug/src/DebugProbes.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import kotlin.coroutines.*
1919
* Debug probes is a dynamic attach mechanism which installs multiple hooks into coroutines machinery.
2020
* It slows down all coroutine-related code, but in return provides a lot of diagnostic information, including
2121
* asynchronous stack-traces and coroutine dumps (similar to [ThreadMXBean.dumpAllThreads] and `jstack` via [DebugProbes.dumpCoroutines].
22+
* All introspecting methods throw [IllegalStateException] if debug probes were not installed.
2223
*
2324
* Installed hooks:
2425
*
@@ -41,6 +42,11 @@ public object DebugProbes {
4142
*/
4243
public var sanitizeStackTraces: Boolean = true
4344

45+
/**
46+
* Determines whether debug probes were [installed][DebugProbes.install].
47+
*/
48+
public val isInstalled: Boolean get() = DebugProbesImpl.isInstalled
49+
4450
/**
4551
* Installs a [DebugProbes] instead of no-op stdlib probes by redefining
4652
* debug probes class using the same class loader as one loaded [DebugProbes] class.

kotlinx-coroutines-debug/src/internal/DebugProbesImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal object DebugProbesImpl {
2929
private val capturedCoroutines = HashSet<CoroutineOwner<*>>()
3030
@Volatile
3131
private var installations = 0
32-
private val isInstalled: Boolean get() = installations > 0
32+
internal val isInstalled: Boolean get() = installations > 0
3333
// To sort coroutines by creation order, used as unique id
3434
private var sequenceNumber: Long = 0
3535

0 commit comments

Comments
 (0)