From 8b33967e2416485d9b2f51ed45a0b3edfa45fa6c Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Mon, 11 Oct 2021 16:49:49 +0300 Subject: [PATCH] Promote the following experimental API to stable * transformWhile * awaitClose and ProducerScope (for callbackFlow and channelFlow) * merge * runningFold, runningReduce and scan --- kotlinx-coroutines-core/common/src/channels/Produce.kt | 8 ++------ .../common/src/flow/operators/Limit.kt | 1 - .../common/src/flow/operators/Merge.kt | 2 -- .../common/src/flow/operators/Transform.kt | 3 --- reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt | 1 - 5 files changed, 2 insertions(+), 13 deletions(-) diff --git a/kotlinx-coroutines-core/common/src/channels/Produce.kt b/kotlinx-coroutines-core/common/src/channels/Produce.kt index 3342fb6ec9..a03e3d8742 100644 --- a/kotlinx-coroutines-core/common/src/channels/Produce.kt +++ b/kotlinx-coroutines-core/common/src/channels/Produce.kt @@ -6,14 +6,11 @@ package kotlinx.coroutines.channels import kotlinx.coroutines.* import kotlin.coroutines.* +import kotlinx.coroutines.flow.* /** - * Scope for the [produce][CoroutineScope.produce] coroutine builder. - * - * **Note: This is an experimental api.** Behavior of producers that work as children in a parent scope with respect - * to cancellation and error handling may change in the future. + * Scope for the [produce][CoroutineScope.produce], [callbackFlow] and [channelFlow] builders. */ -@ExperimentalCoroutinesApi public interface ProducerScope : CoroutineScope, SendChannel { /** * A reference to the channel this coroutine [sends][send] elements to. @@ -45,7 +42,6 @@ public interface ProducerScope : CoroutineScope, SendChannel { * } * ``` */ -@ExperimentalCoroutinesApi public suspend fun ProducerScope<*>.awaitClose(block: () -> Unit = {}) { check(kotlin.coroutines.coroutineContext[Job] === this) { "awaitClose() can only be invoked from the producer context" } try { diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Limit.kt b/kotlinx-coroutines-core/common/src/flow/operators/Limit.kt index 8fbf1a2b0e..734464b557 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Limit.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Limit.kt @@ -112,7 +112,6 @@ public fun Flow.takeWhile(predicate: suspend (T) -> Boolean): Flow = f * } * ``` */ -@ExperimentalCoroutinesApi public fun Flow.transformWhile( @BuilderInference transform: suspend FlowCollector.(value: T) -> Boolean ): Flow = diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt b/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt index 432160f340..228cc9e245 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Merge.kt @@ -90,7 +90,6 @@ public fun Flow>.flattenConcat(): Flow = flow { * Applications of [flowOn], [buffer], and [produceIn] _after_ this operator are fused with * its concurrent merging so that only one properly configured channel is used for execution of merging logic. */ -@ExperimentalCoroutinesApi public fun Iterable>.merge(): Flow { /* * This is a fuseable implementation of the following operator: @@ -114,7 +113,6 @@ public fun Iterable>.merge(): Flow { * Applications of [flowOn], [buffer], and [produceIn] _after_ this operator are fused with * its concurrent merging so that only one properly configured channel is used for execution of merging logic. */ -@ExperimentalCoroutinesApi public fun merge(vararg flows: Flow): Flow = flows.asIterable().merge() /** diff --git a/kotlinx-coroutines-core/common/src/flow/operators/Transform.kt b/kotlinx-coroutines-core/common/src/flow/operators/Transform.kt index a47ae776ca..9b97193227 100644 --- a/kotlinx-coroutines-core/common/src/flow/operators/Transform.kt +++ b/kotlinx-coroutines-core/common/src/flow/operators/Transform.kt @@ -85,7 +85,6 @@ public fun Flow.onEach(action: suspend (T) -> Unit): Flow = transform * * This function is an alias to [runningFold] operator. */ -@ExperimentalCoroutinesApi public fun Flow.scan(initial: R, @BuilderInference operation: suspend (accumulator: R, value: T) -> R): Flow = runningFold(initial, operation) /** @@ -97,7 +96,6 @@ public fun Flow.scan(initial: R, @BuilderInference operation: suspend * ``` * will produce `[], [1], [1, 2], [1, 2, 3]]`. */ -@ExperimentalCoroutinesApi public fun Flow.runningFold(initial: R, @BuilderInference operation: suspend (accumulator: R, value: T) -> R): Flow = flow { var accumulator: R = initial emit(accumulator) @@ -118,7 +116,6 @@ public fun Flow.runningFold(initial: R, @BuilderInference operation: s * ``` * will produce `[1, 3, 6, 10]` */ -@ExperimentalCoroutinesApi public fun Flow.runningReduce(operation: suspend (accumulator: T, value: T) -> T): Flow = flow { var accumulator: Any? = NULL collect { value -> diff --git a/reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt b/reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt index d9228409db..ce68091705 100644 --- a/reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt +++ b/reactive/kotlinx-coroutines-reactor/src/ReactorContext.kt @@ -4,7 +4,6 @@ package kotlinx.coroutines.reactor -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlin.coroutines.* import kotlinx.coroutines.reactive.* import reactor.util.context.*