@@ -118,7 +118,7 @@ This API is used by the `loadContributorsBlocking()` function to fetch the list
118
118
* When you get the response, the result is logged by calling the specific `logRepos()` and `logUsers()` functions (`#3 `).
119
119
If the HTTP response contains an error, this error will be logged here.
120
120
* Finally , get the response' s body, which contains the data you need. For this tutorial, you' ll use an empty list as a
121
- result in case there is an error, and you’ ll log the corresponding error (`#4 `).
121
+ result in case there is an error, and you' ll log the corresponding error (`#4`).
122
122
123
123
2. To avoid repeating `.body() ?: emptyList()`, an extension function `bodyList()` is declared:
124
124
@@ -281,7 +281,7 @@ Make sure to call the logic passed in the callback explicitly. Otherwise, nothin
281
281
282
282
### Use the Retrofit callback API
283
283
284
- In the previous solution, the whole loading logic is moved to the background thread, but that still isn’ t the best use of
284
+ In the previous solution, the whole loading logic is moved to the background thread, but that still isn' t the best use of
285
285
resources. All of the loading requests go sequentially and the thread is blocked while waiting for the loading result,
286
286
while it could have been occupied by other tasks. Specifically, the thread could start loading another request to
287
287
receive the entire result earlier.
@@ -367,7 +367,7 @@ However, this code also fails to achieve our objective. Try to find the answer y
367
367
368
368
#### The second attempted solution for task 3 {initial- collapse- state= " collapsed" }
369
369
370
- Since the loading requests are started concurrently, there’ s no guarantee that the result for the last one comes last. The
370
+ Since the loading requests are started concurrently, there' s no guarantee that the result for the last one comes last. The
371
371
results can come in any order.
372
372
373
373
Thus, if you compare the current index with the `lastIndex` as a condition for completion, you risk losing the results for
@@ -583,7 +583,7 @@ despite all the requests taking place on the main UI thread:
583
583
modify the template for running all of the Kotlin files and enable this option by default.
584
584
585
585
Now all of the code runs on one coroutine, the "load contributors" coroutine mentioned above, denoted as `@coroutine#1`.
586
- While waiting for the result, you shouldn’ t reuse the thread for sending other requests because the code is
586
+ While waiting for the result, you shouldn' t reuse the thread for sending other requests because the code is
587
587
written sequentially. The new request is sent only when the previous result is received.
588
588
589
589
Suspending functions treat the thread fairly and don' t block it for "waiting". However, this doesn' t yet bring any concurrency
@@ -725,7 +725,7 @@ create as many as you need.
725
725
```
726
726
727
727
2. Run the code and check the log. All of the coroutines still run on the main UI thread because
728
- multithreading hasn’ t been employed yet, but you can already see the benefits of running coroutines concurrently.
728
+ multithreading hasn' t been employed yet, but you can already see the benefits of running coroutines concurrently.
729
729
3 . To change this code to run " contributors" coroutines on different threads from the common thread pool,
730
730
specify `Dispatchers .Default ` as the context argument for the `async` function:
731
731
@@ -1347,7 +1347,7 @@ they make life easier when you need to understand what's going on.
1347
1347
1348
1348
## Testing coroutines
1349
1349
1350
- Let’ s now test all solutions to check that the solution with concurrent coroutines is faster than the solution with
1350
+ Let ' s now test all solutions to check that the solution with concurrent coroutines is faster than the solution with
1351
1351
the `suspend` functions, and check that the solution with channels is faster than the simple "progress" one.
1352
1352
1353
1353
In the following task, you' ll compare the total running time of the solutions. You ' ll mock a GitHub service and make
0 commit comments