| /* |
| * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| */ |
| package kotlin.coroutines |
| |
| // DOKKA STUB |
| public interface CoroutineContext { |
| public operator fun <E : Element> get(key: Key<E>): E? |
| public fun <R> fold(initial: R, operation: (R, Element) -> R): R |
| public operator fun plus(context: CoroutineContext): CoroutineContext = TODO() |
| public fun minusKey(key: Key<*>): CoroutineContext |
| public interface Key<E : Element> |
| public interface Element : CoroutineContext { |
| public val key: Key<*> |
| |
| public override operator fun <E : Element> get(key: Key<E>): E? = |
| @Suppress("UNCHECKED_CAST") |
| if (this.key == key) this as E else null |
| |
| public override fun <R> fold(initial: R, operation: (R, Element) -> R): R = |
| operation(initial, this) |
| |
| public override fun minusKey(key: Key<*>): CoroutineContext = |
| if (this.key == key) EmptyCoroutineContext else this |
| } |
| } |
| |
| public object EmptyCoroutineContext : CoroutineContext { |
| private const val serialVersionUID: Long = 0 |
| private fun readResolve(): Any = EmptyCoroutineContext |
| |
| public override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E? = null |
| public override fun <R> fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R = initial |
| public override fun plus(context: CoroutineContext): CoroutineContext = context |
| public override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext = this |
| public override fun hashCode(): Int = 0 |
| public override fun toString(): String = "EmptyCoroutineContext" |
| } |