@@ -11,7 +11,7 @@ import kotlinx.coroutines.channels.Channel.Factory.CONFLATED
11
11
import kotlinx.coroutines.channels.Channel.Factory.RENDEZVOUS
12
12
import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED
13
13
import kotlinx.coroutines.selects.*
14
- import kotlin.jvm .*
14
+ import kotlin.coroutines .*
15
15
16
16
/* *
17
17
* Sender's interface to [Channel].
@@ -295,25 +295,24 @@ public interface ChannelIterator<out E> {
295
295
*/
296
296
public suspend operator fun hasNext (): Boolean
297
297
298
+ @Deprecated(message = " Since 1.3.0, binary compatibility with versions <= 1.2.x" , level = DeprecationLevel .HIDDEN )
299
+ public fun next (continuation : Continuation <* >): Any? = next()
300
+
298
301
/* *
299
- * Retrieves and removes the element from this channel suspending the caller while this channel
300
- * is empty or throws [ClosedReceiveChannelException] if the channel
301
- * [isClosedForReceive][ReceiveChannel.isClosedForReceive] without cause.
302
- * It throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
303
- *
304
- * This suspending function is cancellable. If the [Job] of the current coroutine is cancelled or completed while this
305
- * function is suspended, this function immediately resumes with [CancellationException].
306
- *
307
- * *Cancellation of suspended receive is atomic* -- when this function
308
- * throws [CancellationException] it means that the element was not retrieved from this channel.
309
- * As a side-effect of atomic cancellation, a thread-bound coroutine (to some UI thread, for example) may
310
- * continue to execute even after it was cancelled from the same thread in the case when this receive operation
311
- * was already resumed and the continuation was posted for execution to the thread's queue.
302
+ * Retrieves the element from the current iterator previously removed from the channel by preceding call to [hasNext] or
303
+ * throws [IllegalStateException] if [hasNext] was not invoked.
304
+ * [next] should only be used in pair with [hasNext]:
305
+ * ```
306
+ * while (iterator.hasNext()) {
307
+ * val element = iterator.next()
308
+ * // ... handle element ...
309
+ * }
310
+ * ```
312
311
*
313
- * Note that this function does not check for cancellation when it is not suspended .
314
- * Use [yield] or [CoroutineScope.isActive] to periodically check for cancellation in tight loops if needed .
312
+ * This method throws [ClosedReceiveChannelException] if the channel [isClosedForReceive][ReceiveChannel.isClosedForReceive] without cause .
313
+ * It throws the original [close][SendChannel.close] cause exception if the channel has _failed_ .
315
314
*/
316
- public suspend operator fun next (): E
315
+ public operator fun next (): E
317
316
}
318
317
319
318
/* *
0 commit comments