Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: avoid scrolling sample code; fix test description; add () to functions calls #4080

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/topics/coroutines-and-channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<User> {
fun loadContributorsBlocking(
service: GitHubService,
req: RequestData
Comment on lines +95 to +96
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the indentation here correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is a copy-paste issue from a file with code to the example area in the md file. Fixed it here https://github.com/Kotlin/kotlinx.coroutines/pull/4085/files

): List<User> {
val repos = service
.getOrgReposCall(req.org) // #1
.execute() // #2
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -1206,8 +1210,8 @@ When the channel is full, the next `send` call on it is suspended until more fre
<def title="Rendezvous channel">
<p>The "Rendezvous" channel is a channel without a buffer, the same as a buffered channel with zero size.
One of the functions (<code>send()</code> or <code>receive()</code>) is always suspended until the other is called. </p>
<p>If the <code>send()</code> function is called and there's no suspended <code>receive</code> call ready to process the element, then <code>send()</code>
is suspended. Similarly, if the <code>receive</code> function is called and the channel is empty or, in other words, there's no
<p>If the <code>send()</code> function is called and there's no suspended <code>receive()</code> call ready to process the element, then <code>send()</code>
is suspended. Similarly, if the <code>receive()</code> function is called and the channel is empty or, in other words, there's no
suspended <code>send()</code> call ready to send the element, the <code>receive()</code> call is suspended. </p>
<p>The "rendezvous" name ("a meeting at an agreed time and place") refers to the fact that <code>send()</code> and <code>receive()</code>
should "meet on time".</p>
Expand Down