@@ -9,11 +9,12 @@ import java.lang.management.*
9
9
import kotlin.coroutines.*
10
10
11
11
/* *
12
- * Debug probes support.
12
+ * Kotlin debug probes support.
13
13
*
14
14
* Debug probes is a dynamic attach mechanism which installs multiple hooks into coroutines machinery.
15
- * It slows down all coroutine-related code, but in return provides a lot of diagnostic information, including
16
- * asynchronous stack-traces and coroutine dumps (similar to [ThreadMXBean.dumpAllThreads] and `jstack` via [DebugProbes.dumpCoroutines].
15
+ * It slows down all coroutine-related code, but in return provides diagnostic information, including
16
+ * asynchronous stacktraces, coroutine dumps (similar to [ThreadMXBean.dumpAllThreads] and `jstack`) via [DebugProbes.dumpCoroutines],
17
+ * and programmatic introspection of all alive coroutines.
17
18
* All introspecting methods throw [IllegalStateException] if debug probes were not installed.
18
19
*
19
20
* ### Consistency guarantees
@@ -24,16 +25,26 @@ import kotlin.coroutines.*
24
25
* In practice, it means that for snapshotting operations in progress, for each concurrent coroutine either
25
26
* the state prior to the operation or the state that was reached during the current operation is observed.
26
27
*
27
- * ### Installed hooks
28
- * * `probeCoroutineResumed` is invoked on every [Continuation.resume].
29
- * * `probeCoroutineSuspended` is invoked on every continuation suspension.
30
- * * `probeCoroutineCreated` is invoked on every coroutine creation.
31
- *
32
28
* ### Overhead
33
- * * Every created coroutine is stored in a concurrent hash map and hash map is looked up and
29
+ *
30
+ * - Every created coroutine is stored in a concurrent hash map, and the hash map is looked up in and
34
31
* updated on each suspension and resumption.
35
- * * If [DebugProbes.enableCreationStackTraces] is enabled, stack trace of the current thread is captured on
32
+ * - If [DebugProbes.enableCreationStackTraces] is enabled, stack trace of the current thread is captured on
36
33
* each created coroutine that is a rough equivalent of throwing an exception per each created coroutine.
34
+ *
35
+ * ### Internal machinery and classloading.
36
+ *
37
+ * Under the hood, debug probes replace internal `kotlin.coroutines.jvm.internal.DebugProbesKt` class that has the following
38
+ * empty static methods:
39
+ *
40
+ * - `probeCoroutineResumed` that is invoked on every [Continuation.resume].
41
+ * - `probeCoroutineSuspended` that is invoked on every continuation suspension.
42
+ * - `probeCoroutineCreated` that is invoked on every coroutine creation.
43
+ *
44
+ * with a `kotlinx-coroutines`-specific class to keep track of all the coroutines machinery.
45
+ *
46
+ * The new class is located in the `kotlinx-coroutines-core` module, meaning that all target application classes that use
47
+ * coroutines and `suspend` functions have to be loaded by the classloader in which `kotlinx-coroutines-core` classes are available.
37
48
*/
38
49
@ExperimentalCoroutinesApi
39
50
public object DebugProbes {
0 commit comments