Skip to content

Commit 042b209

Browse files
committed
Merge branch 'master' into develop
2 parents 8c07124 + e478715 commit 042b209

File tree

18 files changed

+104
-82
lines changed

18 files changed

+104
-82
lines changed

CHANGES.md

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

3+
## Version 1.1.1
4+
5+
* Maintenance release, no changes in the codebase
6+
* Kotlin is updated to 1.3.20
7+
* Gradle is updated to 4.10
8+
* Native module is published with Gradle metadata v0.4
9+
310
## Version 1.1.0
411

512
* Kotlin version updated to 1.3.11.

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
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=1.1.0) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/1.1.0)
5+
[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=1.1.1) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/1.1.1)
66

77
Library support for Kotlin coroutines with [multiplatform](#multiplatform) support.
8-
This is a companion version for Kotlin `1.3.11` release.
8+
This is a companion version for Kotlin `1.3.20` release.
99

1010
**NOTE**: `0.30.2` was the last release with Kotlin 1.2 and experimental coroutines.
1111
See [COMPATIBILITY.md](COMPATIBILITY.md) for details of migration onto the stable Kotlin 1.3 coroutines.
@@ -74,15 +74,15 @@ Add dependencies (you can also add other modules that you need):
7474
<dependency>
7575
<groupId>org.jetbrains.kotlinx</groupId>
7676
<artifactId>kotlinx-coroutines-core</artifactId>
77-
<version>1.1.0</version>
77+
<version>1.1.1</version>
7878
</dependency>
7979
```
8080

8181
And make sure that you use the latest Kotlin version:
8282

8383
```xml
8484
<properties>
85-
<kotlin.version>1.3.11</kotlin.version>
85+
<kotlin.version>1.3.20</kotlin.version>
8686
</properties>
8787
```
8888

@@ -92,15 +92,15 @@ Add dependencies (you can also add other modules that you need):
9292

9393
```groovy
9494
dependencies {
95-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0'
95+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
9696
}
9797
```
9898

9999
And make sure that you use the latest Kotlin version:
100100

101101
```groovy
102102
buildscript {
103-
ext.kotlin_version = '1.3.11'
103+
ext.kotlin_version = '1.3.20'
104104
}
105105
```
106106

@@ -118,15 +118,15 @@ Add dependencies (you can also add other modules that you need):
118118

119119
```groovy
120120
dependencies {
121-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0")
121+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1")
122122
}
123123
```
124124

125125
And make sure that you use the latest Kotlin version:
126126

127127
```groovy
128128
plugins {
129-
kotlin("jvm") version "1.3.11"
129+
kotlin("jvm") version "1.3.20"
130130
}
131131
```
132132

@@ -146,7 +146,7 @@ Add [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android)
146146
module as dependency when using `kotlinx.coroutines` on Android:
147147

148148
```groovy
149-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0'
149+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
150150
```
151151
This gives you access to Android [Dispatchers.Main](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-android/kotlinx.coroutines.android/kotlinx.coroutines.-dispatchers/index.html)
152152
coroutine dispatcher and also makes sure that in case of crashed coroutine with unhandled exception this

build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ buildscript {
1212
}
1313
repositories {
1414
jcenter()
15+
maven { url "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/id:1907319/artifacts/content/maven" }
1516
maven { url "https://kotlin.bintray.com/kotlinx" }
1617
maven { url "https://kotlin.bintray.com/kotlin-dev" }
1718
maven { url "https://kotlin.bintray.com/kotlin-eap" }
@@ -63,6 +64,7 @@ allprojects {
6364
google()
6465
}
6566
jcenter()
67+
maven { url "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/id:1907319/artifacts/content/maven" }
6668
maven { url "https://kotlin.bintray.com/kotlin-dev" }
6769
maven { url "https://kotlin.bintray.com/kotlin-eap" }
6870
maven { url "https://kotlin.bintray.com/kotlinx" }

core/kotlinx-coroutines-core/test/CancellableContinuationJvmTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CancellableContinuationJvmTest : TestBase() {
1616
private suspend fun checkToString() {
1717
suspendCancellableCoroutine<Unit> {
1818
it.resume(Unit)
19-
assertTrue(it.toString().contains("kotlinx/coroutines/CancellableContinuationJvmTest.checkToString(CancellableContinuationJvmTest.kt"))
19+
assertTrue(it.toString().contains("kotlinx.coroutines.CancellableContinuationJvmTest.checkToString(CancellableContinuationJvmTest.kt"))
2020
}
2121
}
2222
}

core/kotlinx-coroutines-debug/README.md

+34-50
Original file line numberDiff line numberDiff line change
@@ -18,99 +18,83 @@ of coroutines hierarchy referenced by a [Job] or [CoroutineScope] instances usin
1818
Add `kotlinx-coroutines-debug` to your project test dependencies:
1919
```
2020
dependencies {
21-
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.1.0'
21+
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.1.1'
2222
}
2323
```
2424

2525
### Using as JVM agent
2626

2727
It is possible to use this module as a standalone JVM agent to enable debug probes on the application startup.
28-
You can run your application with an additional argument: `-javaagent:kotlinx-coroutines-debug-1.1.0.jar`.
28+
You can run your application with an additional argument: `-javaagent:kotlinx-coroutines-debug-1.1.1.jar`.
2929
Additionally, on Linux and Mac OS X you can use `kill -5 $pid` command in order to force your application to print all alive coroutines.
3030

3131

3232
### Example of usage
3333

34-
Capabilities of this module can be demonstrated by the following example:
35-
```kotlin
36-
class Computation {
37-
public fun computeValue(): Deferred<String> = GlobalScope.async {
38-
val firstPart = computeFirstPart()
39-
val secondPart = computeSecondPart()
40-
41-
combineResults(firstPart, secondPart)
42-
}
34+
Capabilities of this module can be demonstrated by the following example
35+
(runnable code is [here](test/Example.kt)):
4336

44-
private suspend fun combineResults(firstPart: Deferred<String>, secondPart: Deferred<String>): String {
45-
return firstPart.await() + secondPart.await()
46-
}
37+
```kotlin
38+
suspend fun computeValue(): String = coroutineScope {
39+
val one = async { computeOne() }
40+
val two = async { computeTwo() }
41+
combineResults(one, two)
42+
}
4743

44+
suspend fun combineResults(one: Deferred<String>, two: Deferred<String>): String =
45+
one.await() + two.await()
4846

49-
private suspend fun CoroutineScope.computeFirstPart() = async {
50-
delay(5000)
51-
"4"
52-
}
47+
suspend fun computeOne(): String {
48+
delay(5000)
49+
return "4"
50+
}
5351

54-
private suspend fun CoroutineScope.computeSecondPart() = async {
55-
delay(5000)
56-
"2"
57-
}
52+
suspend fun computeTwo(): String {
53+
delay(5000)
54+
return "2"
5855
}
5956

60-
fun main(args: Array<String>) = runBlocking {
57+
fun main() = runBlocking {
6158
DebugProbes.install()
62-
val computation = Computation()
63-
val deferred = computation.computeValue()
64-
59+
val deferred = async { computeValue() }
6560
// Delay for some time
6661
delay(1000)
67-
62+
// Dump running coroutines
6863
DebugProbes.dumpCoroutines()
69-
7064
println("\nDumping only deferred")
7165
DebugProbes.printJob(deferred)
7266
}
7367
```
7468

7569
Printed result will be:
70+
7671
```
7772
Coroutines dump 2018/11/12 21:44:02
7873
79-
Coroutine "coroutine#2":DeferredCoroutine{Active}@1b26f7b2, state: SUSPENDED
74+
Coroutine "coroutine#2":DeferredCoroutine{Active}@289d1c02, state: SUSPENDED
8075
at kotlinx.coroutines.DeferredCoroutine.await$suspendImpl(Builders.common.kt:99)
81-
at Computation.combineResults(Example.kt:18)
82-
at Computation$computeValue$1.invokeSuspend(Example.kt:14)
76+
at ExampleKt.combineResults(Example.kt:11)
77+
at ExampleKt$computeValue$2.invokeSuspend(Example.kt:7)
78+
at ExampleKt$main$1$deferred$1.invokeSuspend(Example.kt:25)
8379
(Coroutine creation stacktrace)
8480
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt.createCoroutineUnintercepted(IntrinsicsJvm.kt:116)
85-
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:23)
86-
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:109)
87-
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:160)
88-
at kotlinx.coroutines.BuildersKt__Builders_commonKt.async(Builders.common.kt:88)
89-
at kotlinx.coroutines.BuildersKt.async(Unknown Source)
90-
at kotlinx.coroutines.BuildersKt__Builders_commonKt.async$default(Builders.common.kt:81)
81+
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:25)
9182
at kotlinx.coroutines.BuildersKt.async$default(Unknown Source)
92-
at Computation.computeValue(Example.kt:10)
93-
at ExampleKt$main$1.invokeSuspend(Example.kt:36)
83+
at ExampleKt$main$1.invokeSuspend(Example.kt:25)
9484
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
95-
at kotlinx.coroutines.DispatchedTask$DefaultImpls.run(Dispatched.kt:237)
96-
at kotlinx.coroutines.DispatchedContinuation.run(Dispatched.kt:81)
97-
at kotlinx.coroutines.EventLoopBase.processNextEvent(EventLoop.kt:123)
98-
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:69)
99-
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:45)
100-
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
101-
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:35)
85+
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233)
10286
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
103-
at ExampleKt.main(Example.kt:33)
87+
at ExampleKt.main(Example.kt:23)
88+
at ExampleKt.main(Example.kt)
10489
10590
... More coroutines here ...
10691
10792
Dumping only deferred
10893
"coroutine#2":DeferredCoroutine{Active}, continuation is SUSPENDED at line kotlinx.coroutines.DeferredCoroutine.await$suspendImpl(Builders.common.kt:99)
109-
"coroutine#3":DeferredCoroutine{Active}, continuation is SUSPENDED at line Computation$computeFirstPart$2.invokeSuspend(Example.kt:23)
110-
"coroutine#4":DeferredCoroutine{Active}, continuation is SUSPENDED at line Computation$computeSecondPart$2.invokeSuspend(Example.kt:28)
94+
"coroutine#3":DeferredCoroutine{Active}, continuation is SUSPENDED at line ExampleKt.computeOne(Example.kt:14)
95+
"coroutine#4":DeferredCoroutine{Active}, continuation is SUSPENDED at line ExampleKt.computeTwo(Example.kt:19)
11196
```
11297

113-
11498
### Status of the API
11599

116100
API is purely experimental and it is not guaranteed that it won't be changed (while it is marked as `@ExperimentalCoroutinesApi`).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import kotlinx.coroutines.*
2+
import kotlinx.coroutines.debug.*
3+
4+
suspend fun computeValue(): String = coroutineScope {
5+
val one = async { computeOne() }
6+
val two = async { computeTwo() }
7+
combineResults(one, two)
8+
}
9+
10+
suspend fun combineResults(one: Deferred<String>, two: Deferred<String>): String =
11+
one.await() + two.await()
12+
13+
suspend fun computeOne(): String {
14+
delay(5000)
15+
return "4"
16+
}
17+
18+
suspend fun computeTwo(): String {
19+
delay(5000)
20+
return "2"
21+
}
22+
23+
fun main() = runBlocking {
24+
DebugProbes.install()
25+
val deferred = async { computeValue() }
26+
// Delay for some time
27+
delay(1000)
28+
// Dump running coroutines
29+
DebugProbes.dumpCoroutines()
30+
println("\nDumping only deferred")
31+
DebugProbes.printJob(deferred)
32+
}

core/kotlinx-coroutines-test/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Test utilities for `kotlinx.coroutines`. Provides `Dispatchers.setMain` to overr
77
Add `kotlinx-coroutines-test` to your project test dependencies:
88
```
99
dependencies {
10-
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.1.0'
10+
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.1.1'
1111
}
1212
```
1313

gradle.properties

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Kotlin
2-
version=1.1.0-SNAPSHOT
2+
version=1.1.1-SNAPSHOT
33
group=org.jetbrains.kotlinx
4-
kotlin_version=1.3.11
5-
kotlin_native_version=1.3.11
4+
kotlin_version=1.3.20
5+
kotlin_native_version=1.3.20
66

77
# Dependencies
88
junit_version=4.12
9-
atomicFU_version=0.12.0
9+
atomicFU_version=0.12.1
1010
html_version=0.6.8
1111
lincheck_version=2.0
1212
dokka_version=0.9.16-rdev-2-mpp-hacks
13-
bintray_version=1.8.2-SNAPSHOT
13+
bintray_version=1.8.4-jetbrains-5
1414
byte_buddy_version=1.9.3
1515
artifactory_plugin_version=4.7.3
1616

gradle/publish-bintray.gradle

+1-4
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,7 @@ bintrayUpload.doFirst {
117117
if (!isNative()) {
118118
afterEvaluate {
119119
publishing.publications.each { pub ->
120-
pub.gradleModuleMetadataFile = null
121-
tasks.matching { it.name == "generateMetadataFileFor${pub.name.capitalize()}Publication" }.all {
122-
onlyIf { false }
123-
}
120+
pub.moduleDescriptorGenerator = null
124121
}
125122
}
126123
}

gradle/wrapper/gradle-wrapper.jar

1.72 KB
Binary file not shown.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

integration/kotlinx-coroutines-jdk8/src/future/Future.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ public fun <T> CompletionStage<T>.asDeferred(): Deferred<T> {
9595
} catch (e: Throwable) {
9696
// unwrap original cause from ExecutionException
9797
val original = (e as? ExecutionException)?.cause ?: e
98-
CompletableDeferred<T>().also { it.cancel(original) }
98+
CompletableDeferred<T>().also { it.completeExceptionally(original) }
9999
}
100100
}
101101
val result = CompletableDeferred<T>()
102102
whenComplete { value, exception ->
103103
if (exception == null) {
104104
result.complete(value)
105105
} else {
106-
result.cancel(exception)
106+
result.completeExceptionally(exception)
107107
}
108108
}
109109
if (this is Future<*>) result.cancelFutureOnCompletion(this)

native/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ repositories {
4242
}
4343
4444
dependencies {
45-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.1.0'
45+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.1.1'
4646
}
4747
4848
sourceSets {

native/kotlinx-coroutines-core-native/src/internal/Concurrent.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ internal actual fun <E> subscriberList(): MutableList<E> = CopyOnWriteList<E>()
1818
internal actual fun <E> identitySet(expectedSize: Int): MutableSet<E> = HashSet()
1919

2020
@Suppress("ACTUAL_WITHOUT_EXPECT")
21-
internal actual typealias SharedImmutable = kotlin.native.SharedImmutable
21+
internal actual typealias SharedImmutable = kotlin.native.concurrent.SharedImmutable

native/kotlinx-coroutines-core-native/src/internal/ThreadLocal.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package kotlinx.coroutines.internal
66
import kotlin.native.concurrent.*
77

88
@Suppress("ACTUAL_WITHOUT_EXPECT")
9-
internal actual typealias NativeThreadLocal = kotlin.native.ThreadLocal
9+
internal actual typealias NativeThreadLocal = kotlin.native.concurrent.ThreadLocal
1010

1111
internal actual class CommonThreadLocal<T> actual constructor() {
1212
private var value: T? = null

ui/coroutines-guide-ui.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Add dependencies on `kotlinx-coroutines-android` module to the `dependencies { .
165165
`app/build.gradle` file:
166166

167167
```groovy
168-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0"
168+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1"
169169
```
170170

171171
You can clone [kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) project from GitHub onto your
@@ -659,7 +659,7 @@ As you can see, execution immediately continues after [launch], while the corout
659659
for execution later. All UI dispatchers in `kotlinx.coroutines` are implemented this way. Why so?
660660

661661
Basically, the choice here is between "JS-style" asynchronous approach (async actions
662-
are always postponed to be executed later in the even dispatch thread) and "C#-style" approach
662+
are always postponed to be executed later in the event dispatch thread) and "C#-style" approach
663663
(async actions are executed in the invoker thread until the first suspension point).
664664
While, C# approach seems to be more efficient, it ends up with recommendations like
665665
"use `yield` if you need to ....". This is error-prone. JS-style approach is more consistent

0 commit comments

Comments
 (0)