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:
@@ -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>(
|
||||
|
||||
+1
-6
@@ -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>(
|
||||
|
||||
Reference in New Issue
Block a user