Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
qwwdfsad committed May 5, 2023
2 parents 41b4665 + c8ef9ec commit a027d68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions docs/topics/select-expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ the first one that becomes available.

## Selecting from channels

Let us have two producers of strings: `fizz` and `buzz`. The `fizz` produces "Fizz" string every 300 ms:
Let us have two producers of strings: `fizz` and `buzz`. The `fizz` produces "Fizz" string every 500 ms:

```kotlin
fun CoroutineScope.fizz() = produce<String> {
while (true) { // sends "Fizz" every 300 ms
delay(300)
while (true) { // sends "Fizz" every 500 ms
delay(500)
send("Fizz")
}
}
```

And the `buzz` produces "Buzz!" string every 500 ms:
And the `buzz` produces "Buzz!" string every 1000 ms:

```kotlin
fun CoroutineScope.buzz() = produce<String> {
while (true) { // sends "Buzz!" every 500 ms
delay(500)
while (true) { // sends "Buzz!" every 1000 ms
delay(1000)
send("Buzz!")
}
}
Expand Down Expand Up @@ -62,14 +62,14 @@ import kotlinx.coroutines.channels.*
import kotlinx.coroutines.selects.*

fun CoroutineScope.fizz() = produce<String> {
while (true) { // sends "Fizz" every 300 ms
while (true) { // sends "Fizz" every 500 ms
delay(500)
send("Fizz")
}
}

fun CoroutineScope.buzz() = produce<String> {
while (true) { // sends "Buzz!" every 500 ms
while (true) { // sends "Buzz!" every 1000 ms
delay(1000)
send("Buzz!")
}
Expand Down
4 changes: 2 additions & 2 deletions kotlinx-coroutines-core/jvm/test/guide/example-select-01.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import kotlinx.coroutines.channels.*
import kotlinx.coroutines.selects.*

fun CoroutineScope.fizz() = produce<String> {
while (true) { // sends "Fizz" every 300 ms
while (true) { // sends "Fizz" every 500 ms
delay(500)
send("Fizz")
}
}

fun CoroutineScope.buzz() = produce<String> {
while (true) { // sends "Buzz!" every 500 ms
while (true) { // sends "Buzz!" every 1000 ms
delay(1000)
send("Buzz!")
}
Expand Down

0 comments on commit a027d68

Please sign in to comment.