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:
342342<!-- - TEST -->
343343
344344Note, 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 )
346346coroutine 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.
349349However, the benefit of a pipeline that uses channels as shown above is that it can actually use
350350multiple CPU cores if you run it in [ Dispatchers.Default] context.
351351
352352Anyway, this is an extremely impractical way to find prime numbers. In practice, pipelines do involve some
353353other 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
You can’t perform that action at this time.
0 commit comments