Skip to content

Commit 6e9f816

Browse files
committed
Merge branch 'develop'
2 parents 776b370 + 2dafc49 commit 6e9f816

File tree

237 files changed

+9280
-1211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+9280
-1211
lines changed

CHANGES.md

+47
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,52 @@
11
# Change log for kotlinx.coroutines
22

3+
## Version 0.19
4+
5+
* This release is published to Maven Central.
6+
* `DefaultDispatcher` is introduced (see #136):
7+
* `launch`, `async`, `produce`, `actor` and other integration-specific coroutine builders now use
8+
`DefaultDispatcher` as the default value for their `context` parameter.
9+
* When a context is explicitly specified, `newCoroutineContext` function checks if there is any
10+
interceptor/dispatcher defined in the context and uses `DefaultDispatcher` if there is none.
11+
* `DefaultDispatcher` is currently defined to be equal to `CommonPool`.
12+
* Examples in the [guide](coroutines-guide.md) now start with `launch { ... }` code and explanation on the nature
13+
and the need for coroutine context starts in "Coroutine context and dispatchers" section.
14+
* Parent coroutines now wait for their children (see #125):
15+
* Job _completing_ state is introduced in documentation as a state in which parent coroutine waits for its children.
16+
* `Job.attachChild` and `Job.cancelChildren` are introduced.
17+
* `Job.join` now always checks cancellation status of invoker coroutine for predictable behavior when joining
18+
failed child coroutine.
19+
* `Job.cancelAndJoin` extension is introduced.
20+
* `CoroutineContext.cancel` and `CoroutineContext.cancelChildren` extensions are introduced for convenience.
21+
* `withTimeout`/`withTimeoutOrNull` blocks become proper coroutines that have `CoroutineScope` and wait for children, too.
22+
* Diagnostics in cancellation and unexpected exception messages are improved,
23+
coroutine name is included in debug mode.
24+
* Fixed cancellable suspending functions to throw `CancellationException` (as was documented before) even when
25+
the coroutine is cancelled with another application-specific exception.
26+
* `JobCancellationException` is introduced as a specific subclass of `CancellationException` which is
27+
used for coroutines that are cancelled without cause and to wrap application-specific exceptions.
28+
* `Job.getCompletionException` is renamed to `Job.getCancellationException` and return a wrapper exception if needed.
29+
* Introduced `Deferred.getCompletionExceptionOrNull` to get not-wrapped exception result of `async` task.
30+
* Updated docs for `Job` & `Deferred` to explain parent/child relations.
31+
* `select` expression is modularized:
32+
* `SelectClause(0,1,2)` interfaces are introduced, so that synchronization
33+
constructs can define their select clauses without having to modify
34+
the source of the `SelectBuilder` in `kotlinx-corounes-core` module.
35+
* `Job.onJoin`, `Deferred.onAwait`, `Mutex.onLock`, `SendChannel.onSend`, `ReceiveChannel.onReceive`, etc
36+
that were functions before are now properties returning the corresponding select clauses. Old functions
37+
are left in bytecode for backwards compatibility on use-site, but any outside code that was implementing those
38+
interfaces by itself must be updated.
39+
* This opens road to moving channels into a separate module in future updates.
40+
* Renamed `TimeoutException` to `TimeoutCancellationException` (old name is deprecated).
41+
* Fixed various minor problems:
42+
* JavaFx toolkit is now initialized by `JavaFx` context (see #108).
43+
* Fixed lost ACC_STATIC on <clinit> methods (see #116).
44+
* Fixed link to source code from documentation (see #129).
45+
* Fixed `delay` in arbitrary contexts (see #133).
46+
* `kotlinx-coroutines-io` module is introduced. It is a work-in-progress on `ByteReadChannel` and `ByteWriteChannel`
47+
interfaces, their implementations, and related classes to enable convenient coroutine integration with various
48+
asynchronous I/O libraries and sockets. It is currently _unstable_ and **will change** in the next release.
49+
350
## Version 0.18
451

552
* Kotlin 1.1.4 is required to use this version, which enables:

README.md

+11-30
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
[![official JetBrains project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
44
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
5-
[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=0.18) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/0.18)
5+
[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=0.19) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/0.19)
66

77
Library support for Kotlin coroutines.
88
This is a companion version for Kotlin 1.1.4 release (this is the minimal required Kotlin runtime version).
99

1010
## Modules
1111

12-
* [kotlinx-coroutines-core](kotlinx-coroutines-core/README.md) -- core primitives to work with coroutines:
12+
* [core](core/README.md) -- core primitives to work with coroutines:
1313
* `launch`, `async`, `produce`, `actor`, etc coroutine builders;
1414
* `Job` and `Deferred` light-weight future with cancellation support;
1515
* `CommonPool` and other coroutine contexts;
@@ -39,62 +39,43 @@ This is a companion version for Kotlin 1.1.4 release (this is the minimal requir
3939

4040
> Note that these libraries are experimental and are subject to change.
4141
42-
The libraries are published to [kotlinx](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines) bintray repository
43-
and also linked to [JCenter](https://bintray.com/bintray/jcenter?filterByPkgName=kotlinx.coroutines).
44-
45-
These libraries require kotlin compiler version `1.1.4` or later and
46-
require kotlin runtime of the same version as a dependency.
42+
The libraries are published to [kotlinx](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines) bintray repository,
43+
linked to [JCenter](https://bintray.com/bintray/jcenter?filterByPkgName=kotlinx.coroutines) and
44+
pushed to [Maven Central](https://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.jetbrains.kotlinx%20a%3Akotlinx-coroutines).
4745

4846
### Maven
4947

50-
Add Bintray JCenter repository to `<repositories>` section:
51-
52-
```xml
53-
<repository>
54-
<id>central</id>
55-
<url>http://jcenter.bintray.com</url>
56-
</repository>
57-
```
58-
5948
Add dependencies (you can also add other modules that you need):
6049

6150
```xml
6251
<dependency>
6352
<groupId>org.jetbrains.kotlinx</groupId>
6453
<artifactId>kotlinx-coroutines-core</artifactId>
65-
<version>0.18</version>
54+
<version>0.19</version>
6655
</dependency>
6756
```
6857

69-
And make sure that you use the right Kotlin version:
58+
And make sure that you use the latest Kotlin version:
7059

7160
```xml
7261
<properties>
73-
<kotlin.version>1.1.4</kotlin.version>
62+
<kotlin.version>1.1.51</kotlin.version>
7463
</properties>
7564
```
7665

7766
### Gradle
7867

79-
Add Bintray JCenter repository:
80-
81-
```groovy
82-
repositories {
83-
jcenter()
84-
}
85-
```
86-
8768
Add dependencies (you can also add other modules that you need):
8869

8970
```groovy
90-
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.18'
71+
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.19'
9172
```
9273

93-
And make sure that you use the right Kotlin version:
74+
And make sure that you use the latest Kotlin version:
9475

9576
```groovy
9677
buildscript {
97-
ext.kotlin_version = '1.1.4'
78+
ext.kotlin_version = '1.1.51'
9879
}
9980
```
10081

benchmarks/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<parent>
2525
<groupId>org.jetbrains.kotlinx</groupId>
2626
<artifactId>kotlinx-coroutines</artifactId>
27-
<version>0.18-SNAPSHOT</version>
27+
<version>0.19-SNAPSHOT</version>
2828
</parent>
2929

3030
<artifactId>benchmarks</artifactId>

core/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Coroutines core
2+
3+
This directory contains modules that provide core coroutine support.
4+
5+
## Modules
6+
7+
* [kotlinx-coroutines-core](kotlinx-coroutines-core/README.md) -- core coroutine builders and synchronization primitives.
8+
* [kotlinx-coroutines-io](kotlinx-coroutines-io/README.md) -- byte I/O channels (_unstable_, work in progress).
9+

kotlinx-coroutines-core/README.md renamed to core/kotlinx-coroutines-core/README.md

+14-12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Coroutine dispatchers implementing [CoroutineDispatcher]:
1616

1717
| **Name** | **Description**
1818
| --------------------------- | ---------------
19+
| [DefaultDispatcher] | Is equal to [CommonPool]
1920
| [CommonPool] | Confines coroutine execution to a shared pool of threads
2021
| [newSingleThreadContext] | Create new single-threaded coroutine context
2122
| [newFixedThreadPoolContext] | Creates new thread pool of a fixed size
@@ -50,12 +51,12 @@ Top-level suspending functions:
5051

5152
| **Receiver** | **Suspending function** | **Select clause** | **Non-suspending version**
5253
| ---------------- | --------------------------------------------- | ------------------------------------------------ | --------------------------
53-
| [Job] | [join][Job.join] | [onJoin][kotlinx.coroutines.experimental.selects.SelectBuilder.onJoin] | [isCompleted][Job.isCompleted]
54-
| [Deferred] | [await][Deferred.await] | [onAwait][kotlinx.coroutines.experimental.selects.SelectBuilder.onAwait] | [isCompleted][Job.isCompleted]
55-
| [SendChannel][kotlinx.coroutines.experimental.channels.SendChannel] | [send][kotlinx.coroutines.experimental.channels.SendChannel.send] | [onSend][kotlinx.coroutines.experimental.selects.SelectBuilder.onSend] | [offer][kotlinx.coroutines.experimental.channels.SendChannel.offer]
56-
| [ReceiveChannel][kotlinx.coroutines.experimental.channels.ReceiveChannel] | [receive][kotlinx.coroutines.experimental.channels.ReceiveChannel.receive] | [onReceive][kotlinx.coroutines.experimental.selects.SelectBuilder.onReceive] | [poll][kotlinx.coroutines.experimental.channels.ReceiveChannel.poll]
57-
| [ReceiveChannel][kotlinx.coroutines.experimental.channels.ReceiveChannel] | [receiveOrNull][kotlinx.coroutines.experimental.channels.ReceiveChannel.receiveOrNull] | [onReceiveOrNull][kotlinx.coroutines.experimental.selects.SelectBuilder.onReceiveOrNull] | [poll][kotlinx.coroutines.experimental.channels.ReceiveChannel.poll]
58-
| [Mutex][kotlinx.coroutines.experimental.sync.Mutex] | [lock][kotlinx.coroutines.experimental.sync.Mutex.lock] | [onLock][kotlinx.coroutines.experimental.selects.SelectBuilder.onLock] | [tryLock][kotlinx.coroutines.experimental.sync.Mutex.tryLock]
54+
| [Job] | [join][Job.join] | [onJoin][Job.onJoin] | [isCompleted][Job.isCompleted]
55+
| [Deferred] | [await][Deferred.await] | [onAwait][Deferred.onAwait] | [isCompleted][Job.isCompleted]
56+
| [SendChannel][kotlinx.coroutines.experimental.channels.SendChannel] | [send][kotlinx.coroutines.experimental.channels.SendChannel.send] | [onSend][kotlinx.coroutines.experimental.channels.SendChannel.onSend] | [offer][kotlinx.coroutines.experimental.channels.SendChannel.offer]
57+
| [ReceiveChannel][kotlinx.coroutines.experimental.channels.ReceiveChannel] | [receive][kotlinx.coroutines.experimental.channels.ReceiveChannel.receive] | [onReceive][kotlinx.coroutines.experimental.channels.ReceiveChannel.onReceive] | [poll][kotlinx.coroutines.experimental.channels.ReceiveChannel.poll]
58+
| [ReceiveChannel][kotlinx.coroutines.experimental.channels.ReceiveChannel] | [receiveOrNull][kotlinx.coroutines.experimental.channels.ReceiveChannel.receiveOrNull] | [onReceiveOrNull][kotlinx.coroutines.experimental.channels.ReceiveChannel.onReceiveOrNull] | [poll][kotlinx.coroutines.experimental.channels.ReceiveChannel.poll]
59+
| [Mutex][kotlinx.coroutines.experimental.sync.Mutex] | [lock][kotlinx.coroutines.experimental.sync.Mutex.lock] | [onLock][kotlinx.coroutines.experimental.sync.Mutex.onLock] | [tryLock][kotlinx.coroutines.experimental.sync.Mutex.tryLock]
5960
| none | [delay] | [onTimeout][kotlinx.coroutines.experimental.selects.SelectBuilder.onTimeout] | none
6061

6162
Cancellation support for user-defined suspending functions is available with [suspendCancellableCoroutine]
@@ -91,6 +92,7 @@ Select expression to perform multiple suspending operations simultaneously until
9192
[Deferred]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-deferred/index.html
9293
[runBlocking]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/run-blocking.html
9394
[CoroutineDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-coroutine-dispatcher/index.html
95+
[DefaultDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-default-dispatcher.html
9496
[CommonPool]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-common-pool/index.html
9597
[newSingleThreadContext]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/new-single-thread-context.html
9698
[newFixedThreadPoolContext]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/new-fixed-thread-pool-context.html
@@ -104,13 +106,16 @@ Select expression to perform multiple suspending operations simultaneously until
104106
[withTimeout]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/with-timeout.html
105107
[withTimeoutOrNull]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/with-timeout-or-null.html
106108
[Job.join]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-job/join.html
109+
[Job.onJoin]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-job/on-join.html
107110
[Job.isCompleted]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-job/is-completed.html
108111
[Deferred.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-deferred/await.html
112+
[Deferred.onAwait]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-deferred/on-await.html
109113
[suspendCancellableCoroutine]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/suspend-cancellable-coroutine.html
110114
[newCoroutineContext]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/new-coroutine-context.html
111115
<!--- INDEX kotlinx.coroutines.experimental.sync -->
112116
[kotlinx.coroutines.experimental.sync.Mutex]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.sync/-mutex/index.html
113117
[kotlinx.coroutines.experimental.sync.Mutex.lock]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.sync/-mutex/lock.html
118+
[kotlinx.coroutines.experimental.sync.Mutex.onLock]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.sync/-mutex/on-lock.html
114119
[kotlinx.coroutines.experimental.sync.Mutex.tryLock]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.sync/-mutex/try-lock.html
115120
<!--- INDEX kotlinx.coroutines.experimental.channels -->
116121
[kotlinx.coroutines.experimental.channels.produce]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/produce.html
@@ -123,17 +128,14 @@ Select expression to perform multiple suspending operations simultaneously until
123128
[kotlinx.coroutines.experimental.channels.SendChannel.send]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-send-channel/send.html
124129
[kotlinx.coroutines.experimental.channels.ReceiveChannel.receive]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-receive-channel/receive.html
125130
[kotlinx.coroutines.experimental.channels.SendChannel]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-send-channel/index.html
131+
[kotlinx.coroutines.experimental.channels.SendChannel.onSend]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-send-channel/on-send.html
126132
[kotlinx.coroutines.experimental.channels.SendChannel.offer]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-send-channel/offer.html
127133
[kotlinx.coroutines.experimental.channels.ReceiveChannel]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-receive-channel/index.html
134+
[kotlinx.coroutines.experimental.channels.ReceiveChannel.onReceive]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-receive-channel/on-receive.html
128135
[kotlinx.coroutines.experimental.channels.ReceiveChannel.poll]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-receive-channel/poll.html
129136
[kotlinx.coroutines.experimental.channels.ReceiveChannel.receiveOrNull]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-receive-channel/receive-or-null.html
137+
[kotlinx.coroutines.experimental.channels.ReceiveChannel.onReceiveOrNull]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.channels/-receive-channel/on-receive-or-null.html
130138
<!--- INDEX kotlinx.coroutines.experimental.selects -->
131139
[kotlinx.coroutines.experimental.selects.select]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.selects/select.html
132-
[kotlinx.coroutines.experimental.selects.SelectBuilder.onJoin]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.selects/-select-builder/on-join.html
133-
[kotlinx.coroutines.experimental.selects.SelectBuilder.onAwait]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.selects/-select-builder/on-await.html
134-
[kotlinx.coroutines.experimental.selects.SelectBuilder.onSend]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.selects/-select-builder/on-send.html
135-
[kotlinx.coroutines.experimental.selects.SelectBuilder.onReceive]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.selects/-select-builder/on-receive.html
136-
[kotlinx.coroutines.experimental.selects.SelectBuilder.onReceiveOrNull]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.selects/-select-builder/on-receive-or-null.html
137-
[kotlinx.coroutines.experimental.selects.SelectBuilder.onLock]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.selects/-select-builder/on-lock.html
138140
[kotlinx.coroutines.experimental.selects.SelectBuilder.onTimeout]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental.selects/-select-builder/on-timeout.html
139141
<!--- END -->

0 commit comments

Comments
 (0)