Skip to content

Commit d2f2717

Browse files
committed
Merge remote-tracking branch 'origin/master' into develop
2 parents bed3d29 + 6c6df2b commit d2f2717

19 files changed

+435
-422
lines changed

docs/cfg/buildprofiles.xml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<buildprofiles>
4-
<variables>
5-
<enable-browser-edits>true</enable-browser-edits>
6-
<browser-edits-url>https://github.com/Kotlin/kotlinx.coroutines/edit/master/docs/</browser-edits-url>
7-
<allow-indexable-eaps>true</allow-indexable-eaps>
8-
</variables>
9-
<build-profile product="kc"/>
10-
</buildprofiles>
2+
<buildprofiles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/build-profiles.xsd">
3+
<variables>
4+
<enable-browser-edits>true</enable-browser-edits>
5+
<browser-edits-url>https://github.com/Kotlin/kotlinx.coroutines/edit/master/docs/</browser-edits-url>
6+
<allow-indexable-eaps>true</allow-indexable-eaps>
7+
</variables>
8+
<build-profile instance="kc"/>
9+
</buildprofiles>

docs/kc.tree

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<!DOCTYPE product-profile
4-
SYSTEM "https://resources.jetbrains.com/stardust/product-profile.dtd">
5-
6-
<product-profile id="kc"
7-
name="Kotlin coroutines"
8-
start-page="coroutines-guide.md">
9-
10-
<chunk include-id="coroutines">
11-
<toc-element id="coroutines-guide.md"/>
12-
<toc-element id="coroutines-basics.md" accepts-web-file-names="basics.html,coroutines-basic-jvm.html"/>
13-
<toc-element id="coroutines-and-channels.md"/>
14-
<toc-element id="cancellation-and-timeouts.md"/>
15-
<toc-element id="composing-suspending-functions.md"/>
16-
<toc-element id="coroutine-context-and-dispatchers.md"/>
17-
<toc-element id="flow.md"/>
18-
<toc-element id="channels.md"/>
19-
<toc-element id="exception-handling.md"/>
20-
<toc-element id="shared-mutable-state-and-concurrency.md"/>
21-
<toc-element id="select-expression.md"/>
22-
<toc-element id="debug-coroutines-with-idea.md"/>
23-
<toc-element id="debug-flow-with-idea.md"/>
24-
</chunk>
25-
</product-profile>
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<!DOCTYPE instance-profile SYSTEM "https://resources.jetbrains.com/writerside/1.0/product-profile.dtd">
3+
<instance-profile id="kc" name="Kotlin coroutines" start-page="coroutines-guide.md">
4+
<snippet id="coroutines">
5+
<toc-element topic="coroutines-guide.md"/>
6+
<toc-element accepts-web-file-names="basics.html,coroutines-basic-jvm.html" topic="coroutines-basics.md"/>
7+
<toc-element topic="coroutines-and-channels.md"/>
8+
<toc-element topic="cancellation-and-timeouts.md"/>
9+
<toc-element topic="composing-suspending-functions.md"/>
10+
<toc-element topic="coroutine-context-and-dispatchers.md"/>
11+
<toc-element topic="flow.md"/>
12+
<toc-element topic="channels.md"/>
13+
<toc-element topic="exception-handling.md"/>
14+
<toc-element topic="shared-mutable-state-and-concurrency.md"/>
15+
<toc-element topic="select-expression.md"/>
16+
<toc-element topic="debug-coroutines-with-idea.md"/>
17+
<toc-element topic="debug-flow-with-idea.md"/>
18+
</snippet>
19+
</instance-profile>

docs/project.ihp

Lines changed: 0 additions & 14 deletions
This file was deleted.

docs/topics/cancellation-and-timeouts.md

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!--- TEST_NAME CancellationGuideTest -->
2+
<contribute-url>https://github.com/Kotlin/kotlinx.coroutines/edit/master/docs/topics/</contribute-url>
23

34
[//]: # (title: Cancellation and timeouts)
45

@@ -31,10 +32,10 @@ fun main() = runBlocking {
3132
}
3233
```
3334
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
34-
35-
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-cancel-01.kt).
35+
<!--- KNIT example-cancel-01.kt -->
36+
> You can get the full code [here](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-cancel-01.kt).
3637
>
37-
{type="note"}
38+
{style="note"}
3839

3940
It produces the following output:
4041

@@ -85,10 +86,10 @@ fun main() = runBlocking {
8586
}
8687
```
8788
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
88-
89-
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-cancel-02.kt).
89+
<!--- KNIT example-cancel-02.kt -->
90+
> You can get the full code [here](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-cancel-02.kt).
9091
>
91-
{type="note"}
92+
{style="note"}
9293

9394
Run it to see that it continues to print "I'm sleeping" even after cancellation
9495
until the job completes by itself after five iterations.
@@ -130,10 +131,10 @@ fun main() = runBlocking {
130131
}
131132
```
132133
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
133-
134-
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt).
134+
<!--- KNIT example-cancel-03.kt -->
135+
> You can get the full code [here](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt).
135136
>
136-
{type="note"}
137+
{style="note"}
137138

138139
While catching `Exception` is an anti-pattern, this issue may surface in more subtle ways, like when using the
139140
[`runCatching`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/run-catching.html) function,
@@ -172,10 +173,10 @@ fun main() = runBlocking {
172173
}
173174
```
174175
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
175-
176-
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-cancel-04.kt).
176+
<!--- KNIT example-cancel-04.kt -->
177+
> You can get the full code [here](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-cancel-04.kt).
177178
>
178-
{type="note"}
179+
{style="note"}
179180

180181
As you can see, now this loop is cancelled. [isActive] is an extension property
181182
available inside the coroutine via the [CoroutineScope] object.
@@ -188,7 +189,7 @@ main: I'm tired of waiting!
188189
main: Now I can quit.
189190
-->
190191

191-
## Closing resources with `finally`
192+
## Closing resources with finally
192193

193194
Cancellable suspending functions throw [CancellationException] on cancellation, which can be handled in
194195
the usual way. For example, the `try {...} finally {...}` expression and Kotlin's `use` function execute their
@@ -217,10 +218,10 @@ fun main() = runBlocking {
217218
}
218219
```
219220
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
220-
221-
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-cancel-05.kt).
221+
<!--- KNIT example-cancel-05.kt -->
222+
> You can get the full code [here](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-cancel-05.kt).
222223
>
223-
{type="note"}
224+
{style="note"}
224225

225226
Both [join][Job.join] and [cancelAndJoin] wait for all finalization actions to complete,
226227
so the example above produces the following output:
@@ -272,10 +273,10 @@ fun main() = runBlocking {
272273
}
273274
```
274275
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
275-
276-
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-cancel-06.kt).
276+
<!--- KNIT example-cancel-06.kt -->
277+
> You can get the full code [here](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-cancel-06.kt).
277278
>
278-
{type="note"}
279+
{style="note"}
279280

280281
<!--- TEST
281282
job: I'm sleeping 0 ...
@@ -310,10 +311,10 @@ fun main() = runBlocking {
310311
}
311312
```
312313
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
313-
314-
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-cancel-07.kt).
314+
<!--- KNIT example-cancel-07.kt -->
315+
> You can get the full code [here](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-cancel-07.kt).
315316
>
316-
{type="note"}
317+
{style="note"}
317318

318319
It produces the following output:
319320

@@ -353,10 +354,10 @@ fun main() = runBlocking {
353354
}
354355
```
355356
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
356-
357-
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-cancel-08.kt).
357+
<!--- KNIT example-cancel-08.kt -->
358+
> You can get the full code [here](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-cancel-08.kt).
358359
>
359-
{type="note"}
360+
{style="note"}
360361

361362
There is no longer an exception when running this code:
362363

@@ -414,10 +415,10 @@ fun main() {
414415
//sampleEnd
415416
```
416417
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
417-
418-
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-cancel-09.kt).
418+
<!--- KNIT example-cancel-09.kt -->
419+
> You can get the full code [here](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-cancel-09.kt).
419420
>
420-
{type="note"}
421+
{style="note"}
421422

422423
<!--- CLEAR -->
423424

@@ -428,7 +429,7 @@ of your machine. You may need to tweak the timeout in this example to actually s
428429
> since it always happens from the same thread, the one used by `runBlocking`.
429430
> More on that will be explained in the chapter on coroutine context.
430431
>
431-
{type="note"}
432+
{style="note"}
432433

433434
To work around this problem you can store a reference to the resource in a variable instead of returning it
434435
from the `withTimeout` block.
@@ -467,10 +468,10 @@ fun main() {
467468
}
468469
```
469470
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}
470-
471-
> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-cancel-10.kt).
471+
<!--- KNIT example-cancel-10.kt -->
472+
> You can get the full code [here](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-cancel-10.kt).
472473
>
473-
{type="note"}
474+
{style="note"}
474475

475476
This example always prints zero. Resources do not leak.
476477

0 commit comments

Comments
 (0)