5
5
package kotlinx.coroutines.debug
6
6
import kotlinx.coroutines.*
7
7
8
+ /* *
9
+ * A collection of artificial stack trace elements to be included in stack traces by the coroutines machinery.
10
+ */
8
11
@InternalCoroutinesApi
9
12
internal class ArtificialStackFrames {
10
- public fun coroutineCreation (): StackTraceElement = Exception ().stackTrace.toList()[0 ]
11
- public fun coroutineBoundary (): StackTraceElement = Exception ().stackTrace.toList()[0 ]
13
+ /* *
14
+ * Return an artificial stack trace element denoting the boundary between coroutine creation and its execution.
15
+ *
16
+ * Appearance of this function in stack traces does not mean that it was called. Instead, it is used as a marker
17
+ * that separates the part of the stack trace with the code executed in a coroutine from the stack trace of the code
18
+ * that launched the coroutine.
19
+ *
20
+ * In earlier versions of kotlinx-coroutines, this was displayed as "(Coroutine creation stacktrace)", which caused
21
+ * problems for tooling that processes stack traces: https://github.com/Kotlin/kotlinx.coroutines/issues/2291
22
+ *
23
+ * Note that presence of this marker in a stack trace implies that coroutine creation stack traces were enabled.
24
+ */
25
+ fun coroutineCreation (): StackTraceElement = Exception ().stackTrace[0 ]
26
+
27
+ /* *
28
+ * Return an artificial stack trace element denoting a coroutine boundary.
29
+ *
30
+ * Appearance of this function in stack traces does not mean that it was called. Instead, when one coroutine invokes
31
+ * another, this is used as a marker in the stack trace to denote where the execution of one coroutine ends and that
32
+ * of another begins.
33
+ *
34
+ * In earlier versions of kotlinx-coroutines, this was displayed as "(Coroutine boundary)", which caused
35
+ * problems for tooling that processes stack traces: https://github.com/Kotlin/kotlinx.coroutines/issues/2291
36
+ */
37
+ fun coroutineBoundary (): StackTraceElement = Exception ().stackTrace[0 ]
12
38
}
0 commit comments