CoroutineContext Key and Element are now inside CoroutineContext interface itself (just like Map.Entry)

ContinuationInterceptor companion object is named Key
CoroutineContext.Element property for key is named just key
AbstractCoroutineContextElement implements all of CoroutineContext.Element, including key
This commit is contained in:
Roman Elizarov
2017-01-16 10:01:02 +03:00
parent ea7fac07c4
commit 25739a08ea
11 changed files with 98 additions and 118 deletions
+1 -6
View File
@@ -20,15 +20,10 @@ class Controller {
}
}
abstract class ContinuationDispatcher : ContinuationInterceptor {
override val contextKey: CoroutineContextKey<*> = ContinuationInterceptor
abstract class ContinuationDispatcher : AbstractCoroutineContextElement(ContinuationInterceptor), ContinuationInterceptor {
abstract fun <T> dispatchResume(value: T, continuation: Continuation<T>): Boolean
abstract fun dispatchResumeWithException(exception: Throwable, continuation: Continuation<*>): Boolean
override fun <T> interceptContinuation(continuation: Continuation<T>): Continuation<T> = DispatchedContinuation(this, continuation)
override operator fun <E : CoroutineContextElement> get(key: CoroutineContextKey<E>): E? = if (this.contextKey == key) this as E else null
override fun <R> fold(initial: R, operation: (R, CoroutineContextElement) -> R): R = operation(initial, this)
override operator fun plus(context: CoroutineContext): CoroutineContext = this
override fun minusKey(key: CoroutineContextKey<*>): CoroutineContext = if (this.contextKey == key) EmptyCoroutineContext else this
}
private class DispatchedContinuation<T>(
@@ -21,15 +21,10 @@ class Controller {
}
}
abstract class ContinuationDispatcher : ContinuationInterceptor {
override val contextKey: CoroutineContextKey<*> = ContinuationInterceptor
abstract class ContinuationDispatcher : AbstractCoroutineContextElement(ContinuationInterceptor), ContinuationInterceptor {
abstract fun <T> dispatchResume(value: T, continuation: Continuation<T>): Boolean
abstract fun dispatchResumeWithException(exception: Throwable, continuation: Continuation<*>): Boolean
override fun <T> interceptContinuation(continuation: Continuation<T>): Continuation<T> = DispatchedContinuation(this, continuation)
override operator fun <E : CoroutineContextElement> get(key: CoroutineContextKey<E>): E? = if (this.contextKey == key) this as E else null
override fun <R> fold(initial: R, operation: (R, CoroutineContextElement) -> R): R = operation(initial, this)
override operator fun plus(context: CoroutineContext): CoroutineContext = this
override fun minusKey(key: CoroutineContextKey<*>): CoroutineContext = if (this.contextKey == key) EmptyCoroutineContext else this
}
private class DispatchedContinuation<T>(
@@ -1,15 +1,9 @@
@kotlin.Metadata
public abstract class ContinuationDispatcher {
private final @org.jetbrains.annotations.NotNull field contextKey: kotlin.coroutines.CoroutineContextKey
public method <init>(): void
public abstract method dispatchResume(p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): boolean
public abstract method dispatchResumeWithException(@org.jetbrains.annotations.NotNull p0: java.lang.Throwable, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): boolean
public method fold(p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.jvm.functions.Function2): java.lang.Object
public @org.jetbrains.annotations.Nullable method get(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.CoroutineContextKey): kotlin.coroutines.CoroutineContextElement
public @org.jetbrains.annotations.NotNull method getContextKey(): kotlin.coroutines.CoroutineContextKey
public @org.jetbrains.annotations.NotNull method interceptContinuation(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
public @org.jetbrains.annotations.NotNull method minusKey(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.CoroutineContextKey): kotlin.coroutines.CoroutineContext
public @org.jetbrains.annotations.NotNull method plus(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.CoroutineContext): kotlin.coroutines.CoroutineContext
}
@kotlin.Metadata
@@ -1,15 +1,9 @@
@kotlin.Metadata
public abstract class ContinuationDispatcher {
private final @org.jetbrains.annotations.NotNull field contextKey: kotlin.coroutines.CoroutineContextKey
public method <init>(): void
public abstract method dispatchResume(p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): boolean
public abstract method dispatchResumeWithException(@org.jetbrains.annotations.NotNull p0: java.lang.Throwable, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): boolean
public method fold(p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.jvm.functions.Function2): java.lang.Object
public @org.jetbrains.annotations.Nullable method get(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.CoroutineContextKey): kotlin.coroutines.CoroutineContextElement
public @org.jetbrains.annotations.NotNull method getContextKey(): kotlin.coroutines.CoroutineContextKey
public @org.jetbrains.annotations.NotNull method interceptContinuation(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
public @org.jetbrains.annotations.NotNull method minusKey(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.CoroutineContextKey): kotlin.coroutines.CoroutineContext
public @org.jetbrains.annotations.NotNull method plus(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.CoroutineContext): kotlin.coroutines.CoroutineContext
}
@kotlin.Metadata