@@ -100,18 +100,9 @@ public fun consumesAll(vararg channels: ReceiveChannel<*>): CompletionHandler =
100
100
* Makes sure that the given [block] consumes all elements from the given channel
101
101
* by always invoking [cancel][ReceiveChannel.cancel] after the execution of the block.
102
102
*
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
- *
109
103
* 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).
113
104
*/
114
- @ObsoleteCoroutinesApi
105
+ @ExperimentalCoroutinesApi
115
106
public inline fun <E , R > ReceiveChannel<E>.consume (block : ReceiveChannel <E >.() -> R ): R {
116
107
var cause: Throwable ? = null
117
108
try {
@@ -125,21 +116,14 @@ public inline fun <E, R> ReceiveChannel<E>.consume(block: ReceiveChannel<E>.() -
125
116
}
126
117
127
118
/* *
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.
135
122
*
136
123
* The operation is _terminal_.
137
124
* 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).
141
125
*/
142
- @ObsoleteCoroutinesApi
126
+ @ExperimentalCoroutinesApi
143
127
public suspend inline fun <E > ReceiveChannel<E>.consumeEach (action : (E ) -> Unit ) =
144
128
consume {
145
129
for (e in this ) action(e)
0 commit comments