@@ -741,22 +741,22 @@ the standard `lazy` function in cases when computation of the value involves sus
741
741
742
742
We can define async-style functions that invoke ` doSomethingUsefulOne ` and ` doSomethingUsefulTwo `
743
743
_ 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.
746
746
747
747
``` 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 {
750
750
doSomethingUsefulOne()
751
751
}
752
752
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 {
755
755
doSomethingUsefulTwo()
756
756
}
757
757
```
758
758
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.
760
760
However, their use always implies asynchronous (here meaning _ concurrent_ ) execution of their action
761
761
with the invoking code.
762
762
@@ -767,8 +767,8 @@ The following example shows their use outside of coroutine:
767
767
fun main (args : Array <String >) {
768
768
val time = measureTimeMillis {
769
769
// 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 ()
772
772
// but waiting for a result must involve either suspending or blocking.
773
773
// here we use `runBlocking { ... }` to block the main thread while waiting for the result
774
774
runBlocking {
0 commit comments