Skip to content

Commit 8a701ea

Browse files
committed
Promote ReceiveChannel.consumeEach and ReceiveChannel.consume to experimental API
Fixes #1080
1 parent e35637a commit 8a701ea

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

kotlinx-coroutines-core/common/src/channels/Channels.common.kt

+5-21
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,9 @@ public fun consumesAll(vararg channels: ReceiveChannel<*>): CompletionHandler =
100100
* Makes sure that the given [block] consumes all elements from the given channel
101101
* by always invoking [cancel][ReceiveChannel.cancel] after the execution of the block.
102102
*
103-
* **WARNING**: It is planned that in the future a second invocation of this method
104-
* on an channel that is already being consumed is going to fail fast, that is
105-
* immediately throw an [IllegalStateException].
106-
* See [this issue](https://github.com/Kotlin/kotlinx.coroutines/issues/167)
107-
* for details.
108-
*
109103
* The operation is _terminal_.
110-
*
111-
* **Note: This API will become obsolete in future updates with introduction of lazy asynchronous streams.**
112-
* See [issue #254](https://github.com/Kotlin/kotlinx.coroutines/issues/254).
113104
*/
114-
@ObsoleteCoroutinesApi
105+
@ExperimentalCoroutinesApi
115106
public inline fun <E, R> ReceiveChannel<E>.consume(block: ReceiveChannel<E>.() -> R): R {
116107
var cause: Throwable? = null
117108
try {
@@ -125,21 +116,14 @@ public inline fun <E, R> ReceiveChannel<E>.consume(block: ReceiveChannel<E>.() -
125116
}
126117

127118
/**
128-
* Performs the given [action] for each received element.
129-
*
130-
* **WARNING**: It is planned that in the future a second invocation of this method
131-
* on an channel that is already being consumed is going to fail fast, that is
132-
* immediately throw an [IllegalStateException].
133-
* See [this issue](https://github.com/Kotlin/kotlinx.coroutines/issues/167)
134-
* for details.
119+
* Performs the given [action] for each received element and [cancels][ReceiveChannel.cancel]
120+
* the channel after the execution of the block.
121+
* If you need to iterate over the channel without consuming it, a regular `for` loop should be used instead.
135122
*
136123
* The operation is _terminal_.
137124
* This function [consumes][ReceiveChannel.consume] all elements of the original [ReceiveChannel].
138-
*
139-
* **Note: This API will become obsolete in future updates with introduction of lazy asynchronous streams.**
140-
* See [issue #254](https://github.com/Kotlin/kotlinx.coroutines/issues/254).
141125
*/
142-
@ObsoleteCoroutinesApi
126+
@ExperimentalCoroutinesApi
143127
public suspend inline fun <E> ReceiveChannel<E>.consumeEach(action: (E) -> Unit) =
144128
consume {
145129
for (e in this) action(e)

0 commit comments

Comments
 (0)