From d106ac7c362c54fdeffacc6af0b161ed107babaa Mon Sep 17 00:00:00 2001 From: Victoria Petrakovich <78360457+PetrakovichVictoria@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:25:48 +0200 Subject: [PATCH] Docs: avoid scrolling sample code; fix test description; add () to functions calls (#4080) --- docs/topics/coroutines-and-channels.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/topics/coroutines-and-channels.md b/docs/topics/coroutines-and-channels.md index b60d8982a0..4fcb413ce1 100644 --- a/docs/topics/coroutines-and-channels.md +++ b/docs/topics/coroutines-and-channels.md @@ -91,7 +91,10 @@ This API is used by the `loadContributorsBlocking()` function to fetch the list 1. Open `src/tasks/Request1Blocking.kt` to see its implementation: ```kotlin - fun loadContributorsBlocking(service: GitHubService, req: RequestData): List { + fun loadContributorsBlocking( + service: GitHubService, + req: RequestData + ): List { val repos = service .getOrgReposCall(req.org) // #1 .execute() // #2 @@ -328,7 +331,8 @@ fun loadContributorsCallbacks( * The logic for handling the responses is extracted into callbacks: the corresponding lambdas start at lines `#1` and `#2`. However, the provided solution doesn't work. If you run the program and load contributors by choosing the _CALLBACKS_ -option, you'll see that nothing is shown. However, the tests that immediately return the result pass. +option, you'll see that nothing is shown. However, the test from `Request3CallbacksKtTest` immediately returns the result +that it successfully passed. Think about why the given code doesn't work as expected and try to fix it, or see the solutions below. @@ -1206,8 +1210,8 @@ When the channel is full, the next `send` call on it is suspended until more fre

The "Rendezvous" channel is a channel without a buffer, the same as a buffered channel with zero size. One of the functions (send() or receive()) is always suspended until the other is called.

-

If the send() function is called and there's no suspended receive call ready to process the element, then send() -is suspended. Similarly, if the receive function is called and the channel is empty or, in other words, there's no +

If the send() function is called and there's no suspended receive() call ready to process the element, then send() +is suspended. Similarly, if the receive() function is called and the channel is empty or, in other words, there's no suspended send() call ready to send the element, the receive() call is suspended.

The "rendezvous" name ("a meeting at an agreed time and place") refers to the fact that send() and receive() should "meet on time".