Skip to content

Commit 7e94e70

Browse files
MarcinMoskalaelizarov
authored andcommitted
Update coroutines-guide.md
This tutorial suggests just Async suffix: https://github.com/Kotlin/kotlin-coroutines/blob/master/kotlin-coroutines-informal.md#asynchronous-programming-styles Also, there was "of" instead of "or"
1 parent 09ca3b6 commit 7e94e70

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

core/kotlinx-coroutines-core/src/test/kotlin/guide/example-compose-04.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ suspend fun doSomethingUsefulTwo(): Int {
3030
return 29
3131
}
3232

33-
// The result type of asyncSomethingUsefulOne is Deferred<Int>
34-
fun asyncSomethingUsefulOne() = async {
33+
// The result type of somethingUsefulOneAsync is Deferred<Int>
34+
fun somethingUsefulOneAsync() = async {
3535
doSomethingUsefulOne()
3636
}
3737

38-
// The result type of asyncSomethingUsefulTwo is Deferred<Int>
39-
fun asyncSomethingUsefulTwo() = async {
38+
// The result type of somethingUsefulTwoAsync is Deferred<Int>
39+
fun somethingUsefulTwoAsync() = async {
4040
doSomethingUsefulTwo()
4141
}
4242

4343
// note, that we don't have `runBlocking` to the right of `main` in this example
4444
fun main(args: Array<String>) {
4545
val time = measureTimeMillis {
4646
// we can initiate async actions outside of a coroutine
47-
val one = asyncSomethingUsefulOne()
48-
val two = asyncSomethingUsefulTwo()
47+
val one = somethingUsefulOneAsync()
48+
val two = somethingUsefulTwoAsync()
4949
// but waiting for a result must involve either suspending or blocking.
5050
// here we use `runBlocking { ... }` to block the main thread while waiting for the result
5151
runBlocking {

coroutines-guide.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -741,22 +741,22 @@ the standard `lazy` function in cases when computation of the value involves sus
741741

742742
We can define async-style functions that invoke `doSomethingUsefulOne` and `doSomethingUsefulTwo`
743743
_asynchronously_ using [async] coroutine builder. It is a good style to name such functions with
744-
either "async" prefix of "Async" suffix to highlight the fact that they only start asynchronous
745-
computation and one needs to use the resulting deferred value to get the result.
744+
"Async" suffix to highlight the fact that they only start asynchronous computation and one needs
745+
to use the resulting deferred value to get the result.
746746

747747
```kotlin
748-
// The result type of asyncSomethingUsefulOne is Deferred<Int>
749-
fun asyncSomethingUsefulOne() = async {
748+
// The result type of somethingUsefulOneAsync is Deferred<Int>
749+
fun somethingUsefulOneAsync() = async {
750750
doSomethingUsefulOne()
751751
}
752752

753-
// The result type of asyncSomethingUsefulTwo is Deferred<Int>
754-
fun asyncSomethingUsefulTwo() = async {
753+
// The result type of somethingUsefulTwoAsync is Deferred<Int>
754+
fun somethingUsefulTwoAsync() = async {
755755
doSomethingUsefulTwo()
756756
}
757757
```
758758

759-
Note, that these `asyncXXX` function are **not** _suspending_ functions. They can be used from anywhere.
759+
Note, that these `xxxAsync` functions are **not** _suspending_ functions. They can be used from anywhere.
760760
However, their use always implies asynchronous (here meaning _concurrent_) execution of their action
761761
with the invoking code.
762762

@@ -767,8 +767,8 @@ The following example shows their use outside of coroutine:
767767
fun main(args: Array<String>) {
768768
val time = measureTimeMillis {
769769
// we can initiate async actions outside of a coroutine
770-
val one = asyncSomethingUsefulOne()
771-
val two = asyncSomethingUsefulTwo()
770+
val one = somethingUsefulOneAsync()
771+
val two = somethingUsefulTwoAsync()
772772
// but waiting for a result must involve either suspending or blocking.
773773
// here we use `runBlocking { ... }` to block the main thread while waiting for the result
774774
runBlocking {

0 commit comments

Comments
 (0)