CoroutineName

data class CoroutineName : AbstractCoroutineContextElement (source)

User-specified name of coroutine. This name is used in debugging mode. See newCoroutineContext for the description of coroutine debugging facilities.

Types

Key

companion object Key : Key<CoroutineName>

Key for CoroutineName instance in the coroutine context.

Constructors

<init>

CoroutineName(name: String)

User-specified name of coroutine. This name is used in debugging mode. See newCoroutineContext for the description of coroutine debugging facilities.

Properties

name

val name: String

User-defined coroutine name.

Functions

toString

fun toString(): String

Returns a string representation of the object.

Extension Properties

isActive

Returns true when the Job of the coroutine in this context is still active (has not completed and was not cancelled yet).

Extension Functions

cancel

fun CoroutineContext.cancel(
    cause: CancellationException? = null
): Unit

Cancels Job of this context with an optional cancellation cause. See Job.cancel for details.

cancelChildren

fun CoroutineContext.cancelChildren(
    cause: CancellationException? = null
): Unit

Cancels all children of the Job in this context, without touching the state of this job itself with an optional cancellation cause. See Job.cancel. It does not do anything if there is no job in the context or it has no children.

ensureActive

fun CoroutineContext.ensureActive(): Unit

Ensures that job in the current context is active. Throws IllegalStateException if the context does not have a job in it.