xref: /aosp_15_r20/external/kotlinx.coroutines/kotlinx-coroutines-core/common/src/CoroutineName.kt (revision 7a7160fed73afa6648ef8aa100d4a336fe921d9a)
1 package kotlinx.coroutines
2 
3 import kotlin.coroutines.AbstractCoroutineContextElement
4 import kotlin.coroutines.CoroutineContext
5 
6 /**
7  * User-specified name of coroutine. This name is used in debugging mode.
8  * See [newCoroutineContext][CoroutineScope.newCoroutineContext] for the description of coroutine debugging facilities.
9  */
10 public data class CoroutineName(
11     /**
12      * User-defined coroutine name.
13      */
14     val name: String
15 ) : AbstractCoroutineContextElement(CoroutineName) {
16     /**
17      * Key for [CoroutineName] instance in the coroutine context.
18      */
19     public companion object Key : CoroutineContext.Key<CoroutineName>
20 
21     /**
22      * Returns a string representation of the object.
23      */
toStringnull24     override fun toString(): String = "CoroutineName($name)"
25 }
26