File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -342,16 +342,16 @@ The output of this code is:
342
342
<!-- - TEST -->
343
343
344
344
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 )
346
346
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 ` ,
348
348
` ReceiveChannel ` with ` Iterator ` , and get rid of the coroutine scope. You will not need ` runBlocking ` either.
349
349
However, the benefit of a pipeline that uses channels as shown above is that it can actually use
350
350
multiple CPU cores if you run it in [ Dispatchers.Default] context.
351
351
352
352
Anyway, this is an extremely impractical way to find prime numbers. In practice, pipelines do involve some
353
353
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
355
355
` produce ` , which is fully asynchronous.
356
356
357
357
### Fan-out
You can’t perform that action at this time.
0 commit comments