Roman Elizarov | f16fd27 | 2017-02-07 11:26:00 +0300 | [diff] [blame] | 1 | /* |
Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame^] | 2 | * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
Roman Elizarov | f16fd27 | 2017-02-07 11:26:00 +0300 | [diff] [blame] | 3 | */ |
| 4 | |
Roman Elizarov | 3754f95 | 2017-01-18 20:47:54 +0300 | [diff] [blame] | 5 | package kotlinx.coroutines.experimental |
| 6 | |
Roman Elizarov | ea4a51b | 2017-01-31 12:01:25 +0300 | [diff] [blame] | 7 | import kotlin.coroutines.experimental.AbstractCoroutineContextElement |
| 8 | import kotlin.coroutines.experimental.CoroutineContext |
Roman Elizarov | 3754f95 | 2017-01-18 20:47:54 +0300 | [diff] [blame] | 9 | |
| 10 | /** |
| 11 | * User-specified name of coroutine. This name is used in debugging mode. |
| 12 | * See [newCoroutineContext] for the description of coroutine debugging facilities. |
| 13 | */ |
Roman Elizarov | f138bbc | 2017-02-09 19:13:08 +0300 | [diff] [blame] | 14 | public data class CoroutineName( |
| 15 | /** |
| 16 | * User-defined coroutine name. |
| 17 | */ |
| 18 | val name: String |
| 19 | ) : AbstractCoroutineContextElement(CoroutineName) { |
| 20 | /** |
| 21 | * Key for [CoroutineName] instance in the coroutine context. |
| 22 | */ |
Roman Elizarov | 3754f95 | 2017-01-18 20:47:54 +0300 | [diff] [blame] | 23 | public companion object Key : CoroutineContext.Key<CoroutineName> |
Roman Elizarov | f138bbc | 2017-02-09 19:13:08 +0300 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * Returns a string representation of the object. |
| 27 | */ |
Roman Elizarov | 3754f95 | 2017-01-18 20:47:54 +0300 | [diff] [blame] | 28 | override fun toString(): String = "CoroutineName($name)" |
| 29 | } |