Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix typos in Cancellation and Timeouts docs #3317

Merged
merged 1 commit into from Jun 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/topics/cancellation-and-timeouts.md
Expand Up @@ -137,7 +137,7 @@ fun main() = runBlocking {

While catching `Exception` is an anti-pattern, this issue may surface in more subtle ways, like when using the
[`runCatching`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/run-catching.html) function,
which does not know rethrow [CancellationException].
which does not rethrow [CancellationException].

## Making computation code cancellable

Expand Down Expand Up @@ -190,8 +190,8 @@ main: Now I can quit.

## Closing resources with `finally`

Cancellable suspending functions throw [CancellationException] on cancellation which can be handled in
the usual way. For example, `try {...} finally {...}` expression and Kotlin `use` function execute their
Cancellable suspending functions throw [CancellationException] on cancellation, which can be handled in
the usual way. For example, the `try {...} finally {...}` expression and Kotlin's `use` function execute their
finalization actions normally when a coroutine is cancelled:

```kotlin
Expand Down Expand Up @@ -423,13 +423,13 @@ fun main() {
If you run the above code you'll see that it does not always print zero, though it may depend on the timings
of your machine you may need to tweak timeouts in this example to actually see non-zero values.

> Note, that incrementing and decrementing `acquired` counter here from 100K coroutines is completely safe,
> Note that incrementing and decrementing `acquired` counter here from 100K coroutines is completely safe,
> since it always happens from the same main thread. More on that will be explained in the chapter
> on coroutine context.
>
{type="note"}

To workaround this problem you can store a reference to the resource in the variable as opposed to returning it
To work around this problem you can store a reference to the resource in the variable as opposed to returning it
from the `withTimeout` block.

```kotlin
Expand Down