Skip to content

Commit 153e21f

Browse files
mlegyelizarov
authored andcommitted
Update Channels docs to Koltin 1.3
Use `sequence` and `iterator` instead of `buildSequence` and `buildIterator`.
1 parent 325b0ad commit 153e21f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/channels.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,16 @@ The output of this code is:
342342
<!--- TEST -->
343343

344344
Note, that you can build the same pipeline using
345-
[`buildIterator`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/build-iterator.html)
345+
[`iterator`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/iterator.html)
346346
coroutine builder from the standard library.
347-
Replace `produce` with `buildIterator`, `send` with `yield`, `receive` with `next`,
347+
Replace `produce` with `iterator`, `send` with `yield`, `receive` with `next`,
348348
`ReceiveChannel` with `Iterator`, and get rid of the coroutine scope. You will not need `runBlocking` either.
349349
However, the benefit of a pipeline that uses channels as shown above is that it can actually use
350350
multiple CPU cores if you run it in [Dispatchers.Default] context.
351351

352352
Anyway, this is an extremely impractical way to find prime numbers. In practice, pipelines do involve some
353353
other suspending invocations (like asynchronous calls to remote services) and these pipelines cannot be
354-
built using `buildSequence`/`buildIterator`, because they do not allow arbitrary suspension, unlike
354+
built using `sequence`/`iterator`, because they do not allow arbitrary suspension, unlike
355355
`produce`, which is fully asynchronous.
356356

357357
### Fan-out

0 commit comments

Comments
 (0)