@@ -9,11 +9,12 @@ import java.lang.management.*
99import kotlin.coroutines.*
1010
1111/* *
12- * Debug probes support.
12+ * Kotlin debug probes support.
1313 *
1414 * 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.
1718 * All introspecting methods throw [IllegalStateException] if debug probes were not installed.
1819 *
1920 * ### Consistency guarantees
@@ -24,16 +25,26 @@ import kotlin.coroutines.*
2425 * In practice, it means that for snapshotting operations in progress, for each concurrent coroutine either
2526 * the state prior to the operation or the state that was reached during the current operation is observed.
2627 *
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- *
3228 * ### 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
3431 * 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
3633 * 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.
3748 */
3849@ExperimentalCoroutinesApi
3950public object DebugProbes {
0 commit comments