@@ -370,7 +370,7 @@ flowable that sends five integers from 1 to 5.
370
370
It prints a message to the output before invocation of
371
371
suspending [ send] [ SendChannel.send ] function, so that we can study how it operates.
372
372
373
- The integers are generated in [ CommonPool ] , but subscription is shifted
373
+ The integers are generated in the context of the main thread , but subscription is shifted
374
374
to another thread using Rx
375
375
[ observeOn] ( http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html#observeOn(io.reactivex.Scheduler,%20boolean,%20int) )
376
376
operator with a buffer of size 1.
@@ -383,9 +383,9 @@ import io.reactivex.schedulers.Schedulers
383
383
-->
384
384
385
385
``` kotlin
386
- fun main (args : Array <String >) {
387
- // coroutine -- fast producer of elements in common pool
388
- val source = rxFlowable(CommonPool ) {
386
+ fun main (args : Array <String >) = runBlocking< Unit > {
387
+ // coroutine -- fast producer of elements in the context of the main thread
388
+ val source = rxFlowable(context ) {
389
389
for (x in 1 .. 5 ) {
390
390
println (" Sending $x ..." )
391
391
send(x) // this is a suspending function
@@ -399,7 +399,7 @@ fun main(args: Array<String>) {
399
399
println (" Received $x " )
400
400
Thread .sleep(200 ) // 200 ms to process each item
401
401
}
402
- Thread .sleep (2000 ) // hold on main thread for couple of seconds
402
+ delay (2000 ) // suspend main thread for couple of seconds
403
403
}
404
404
```
405
405
@@ -940,9 +940,9 @@ coroutines for complex pipelines with fan-in and fan-out between multiple worker
940
940
<!-- - DOCS_ROOT kotlinx-coroutines-core/target/dokka/kotlinx-coroutines-core -->
941
941
<!-- - INDEX kotlinx.coroutines.experimental -->
942
942
[ runBlocking ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/run-blocking.html
943
- [ CommonPool ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-common-pool/index.html
944
943
[ launch ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/launch.html
945
944
[ CoroutineScope.context ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-coroutine-scope/context.html
945
+ [ CommonPool ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-common-pool/index.html
946
946
[ Unconfined ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-unconfined/index.html
947
947
[ Job.join ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-job/join.html
948
948
<!-- - INDEX kotlinx.coroutines.experimental.channels -->
0 commit comments