Skip to content

Commit 583ec6e

Browse files
authored
Merge pull request #2001 from Kotlin/version-1.3.6
Version 1.3.6
2 parents ae6b2c4 + a922194 commit 583ec6e

File tree

250 files changed

+7474
-1770
lines changed

Some content is hidden

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

250 files changed

+7474
-1770
lines changed

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGES.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Change log for kotlinx.coroutines
22

3+
## Version 1.3.6
4+
5+
### Flow
6+
7+
* `StateFlow`, new primitive for state handling (#1973, #1816, #395). The `StateFlow` is designed to eventually replace `ConflatedBroadcastChannel` for state publication scenarios. Please, try it and share your feedback. Note, that Flow-based primitives to publish events will be added later. For events you should continue to either use `BroadcastChannel(1)`, if you put events into the `StateFlow`, protect them from double-processing with flags.
8+
* `Flow.onEmpty` operator is introduced (#1890).
9+
* Behavioural change in `Flow.onCompletion`, it is aligned with `invokeOnCompletion` now and passes `CancellationException` to its cause parameter (#1693).
10+
* A lot of Flow operators have left its experimental status and are promoted to stable API.
11+
12+
### Other
13+
14+
* `runInterruptible` primitive to tie cancellation with thread interruption for blocking calls. Contributed by @jxdabc (#1947).
15+
* Integration module with RxJava3 is introduced. Contributed by @ZacSweers (#1883)
16+
* Integration with [BlockHound](https://github.com/reactor/BlockHound) in `kotlinx-coroutines-debug` module (#1821, #1060).
17+
* Memory leak in ArrayBroadcastChannel is fixed (#1885).
18+
* Behavioural change in `suspendCancellableCoroutine`, cancellation is established before invoking passed block argument (#1671).
19+
* Debug agent internals are moved into `kotlinx-coroutines-core` for better integration with IDEA. It should not affect library users and all the redundant code should be properly eliminated with R8.
20+
* ClassCastException with reusable continuations bug is fixed (#1966).
21+
* More precise scheduler detection for `Executor.asCoroutineDispatcher` (#1992).
22+
* Kotlin updated to 1.3.71.
23+
324
## Version 1.3.5
425

526
* `firstOrNull` operator. Contributed by @bradynpoulsen.

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
[![official JetBrains project](https://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)](https://www.apache.org/licenses/LICENSE-2.0)
5-
[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=1.3.5) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/1.3.5)
5+
[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=1.3.6) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/1.3.6)
66

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

1010
```kotlin
1111
suspend fun main() = coroutineScope {
@@ -47,6 +47,7 @@ suspend fun main() = coroutineScope {
4747
* Reactive Streams ([Publisher.collect], [Publisher.awaitSingle], [publish], etc),
4848
* Flow (JDK 9) (the same interface as for Reactive Streams),
4949
* RxJava 2.x ([rxFlowable], [rxSingle], etc), and
50+
* RxJava 3.x ([rxFlowable], [rxSingle], etc), and
5051
* Project Reactor ([flux], [mono], etc).
5152
* [ui](ui/README.md) — modules that provide coroutine dispatchers for various single-threaded UI libraries:
5253
* Android, JavaFX, and Swing.
@@ -83,15 +84,15 @@ Add dependencies (you can also add other modules that you need):
8384
<dependency>
8485
<groupId>org.jetbrains.kotlinx</groupId>
8586
<artifactId>kotlinx-coroutines-core</artifactId>
86-
<version>1.3.5</version>
87+
<version>1.3.6</version>
8788
</dependency>
8889
```
8990

9091
And make sure that you use the latest Kotlin version:
9192

9293
```xml
9394
<properties>
94-
<kotlin.version>1.3.70</kotlin.version>
95+
<kotlin.version>1.3.71</kotlin.version>
9596
</properties>
9697
```
9798

@@ -101,15 +102,15 @@ Add dependencies (you can also add other modules that you need):
101102

102103
```groovy
103104
dependencies {
104-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
105+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6'
105106
}
106107
```
107108

108109
And make sure that you use the latest Kotlin version:
109110

110111
```groovy
111112
buildscript {
112-
ext.kotlin_version = '1.3.70'
113+
ext.kotlin_version = '1.3.71'
113114
}
114115
```
115116

@@ -127,15 +128,15 @@ Add dependencies (you can also add other modules that you need):
127128

128129
```groovy
129130
dependencies {
130-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5")
131+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6")
131132
}
132133
```
133134

134135
And make sure that you use the latest Kotlin version:
135136

136137
```groovy
137138
plugins {
138-
kotlin("jvm") version "1.3.70"
139+
kotlin("jvm") version "1.3.71"
139140
}
140141
```
141142

@@ -146,7 +147,7 @@ Make sure that you have either `jcenter()` or `mavenCentral()` in the list of re
146147
Core modules of `kotlinx.coroutines` are also available for
147148
[Kotlin/JS](#js) and [Kotlin/Native](#native).
148149
In common code that should get compiled for different platforms, add dependency to
149-
[`kotlinx-coroutines-core-common`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-common/1.3.5/jar)
150+
[`kotlinx-coroutines-core-common`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-common/1.3.6/jar)
150151
(follow the link to get the dependency declaration snippet).
151152

152153
### Android
@@ -155,7 +156,7 @@ Add [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android)
155156
module as dependency when using `kotlinx.coroutines` on Android:
156157

157158
```groovy
158-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'
159+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6'
159160
```
160161

161162
This gives you access to Android [Dispatchers.Main]
@@ -171,15 +172,15 @@ For more details see ["Optimization" section for Android](ui/kotlinx-coroutines-
171172
### JS
172173

173174
[Kotlin/JS](https://kotlinlang.org/docs/reference/js-overview.html) version of `kotlinx.coroutines` is published as
174-
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.3.5/jar)
175+
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.3.6/jar)
175176
(follow the link to get the dependency declaration snippet).
176177

177178
You can also use [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) package via NPM.
178179

179180
### Native
180181

181182
[Kotlin/Native](https://kotlinlang.org/docs/reference/native-overview.html) version of `kotlinx.coroutines` is published as
182-
[`kotlinx-coroutines-core-native`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-native/1.3.5/jar)
183+
[`kotlinx-coroutines-core-native`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-native/1.3.6/jar)
183184
(follow the link to get the dependency declaration snippet).
184185

185186
Only single-threaded code (JS-style) on Kotlin/Native is currently supported.
@@ -288,6 +289,8 @@ The `develop` branch is pushed to `master` during release.
288289
<!--- INDEX kotlinx.coroutines.rx2 -->
289290
[rxFlowable]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-rx2/kotlinx.coroutines.rx2/rx-flowable.html
290291
[rxSingle]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-rx2/kotlinx.coroutines.rx2/rx-single.html
292+
<!--- MODULE kotlinx-coroutines-rx2 -->
293+
<!--- INDEX kotlinx.coroutines.rx2 -->
291294
<!--- MODULE kotlinx-coroutines-reactor -->
292295
<!--- INDEX kotlinx.coroutines.reactor -->
293296
[flux]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/flux.html

benchmarks/build.gradle

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

benchmarks/build.gradle.kts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
6+
7+
plugins {
8+
id("net.ltgt.apt")
9+
id("com.github.johnrengelman.shadow")
10+
id("me.champeau.gradle.jmh")
11+
}
12+
13+
repositories {
14+
maven("https://repo.typesafe.com/typesafe/releases/")
15+
}
16+
17+
tasks.withType<KotlinCompile>().configureEach {
18+
kotlinOptions.jvmTarget = "1.8"
19+
}
20+
21+
tasks.compileJmhKotlin {
22+
kotlinOptions.freeCompilerArgs += "-Xjvm-default=enable"
23+
}
24+
25+
/*
26+
* Due to a bug in the inliner it sometimes does not remove inlined symbols (that are later renamed) from unused code paths,
27+
* and it breaks JMH that tries to post-process these symbols and fails because they are renamed.
28+
*/
29+
val removeRedundantFiles = tasks.register<Delete>("removeRedundantFiles") {
30+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$buildHistoOnScore\$1\$\$special\$\$inlined\$filter\$1\$1.class")
31+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$nBlanks\$1\$\$special\$\$inlined\$map\$1\$1.class")
32+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$score2\$1\$\$special\$\$inlined\$map\$1\$1.class")
33+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$bonusForDoubleLetter\$1\$\$special\$\$inlined\$map\$1\$1.class")
34+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$nBlanks\$1\$\$special\$\$inlined\$map\$1\$2\$1.class")
35+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$bonusForDoubleLetter\$1\$\$special\$\$inlined\$map\$1\$2\$1.class")
36+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$score2\$1\$\$special\$\$inlined\$map\$1\$2\$1.class")
37+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOptKt\$\$special\$\$inlined\$collect\$1\$1.class")
38+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOptKt\$\$special\$\$inlined\$collect\$2\$1.class")
39+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$histoOfLetters\$1\$\$special\$\$inlined\$fold\$1\$1.class")
40+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleBase\$play\$buildHistoOnScore\$1\$\$special\$\$inlined\$filter\$1\$1.class")
41+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleBase\$play\$histoOfLetters\$1\$\$special\$\$inlined\$fold\$1\$1.class")
42+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble//SaneFlowPlaysScrabble\$play\$buildHistoOnScore\$1\$\$special\$\$inlined\$filter\$1\$1.class")
43+
44+
// Primes
45+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/misc/Numbers\$\$special\$\$inlined\$filter\$1\$2\$1.class")
46+
delete("$buildDir/classes/kotlin/jmh/benchmarks/flow/misc/Numbers\$\$special\$\$inlined\$filter\$1\$1.class")
47+
}
48+
49+
tasks.jmhRunBytecodeGenerator {
50+
dependsOn(removeRedundantFiles)
51+
}
52+
53+
// It is better to use the following to run benchmarks, otherwise you may get unexpected errors:
54+
// ./gradlew --no-daemon cleanJmhJar jmh -Pjmh="MyBenchmark"
55+
jmh {
56+
jmhVersion = "1.21"
57+
duplicateClassesStrategy = DuplicatesStrategy.INCLUDE
58+
failOnError = true
59+
resultFormat = "CSV"
60+
project.findProperty("jmh")?.also {
61+
include = listOf(".*$it.*")
62+
}
63+
// includeTests = false
64+
}
65+
66+
tasks.jmhJar {
67+
baseName = "benchmarks"
68+
classifier = null
69+
version = null
70+
destinationDir = file("$rootDir")
71+
}
72+
73+
dependencies {
74+
compile("org.openjdk.jmh:jmh-core:1.21")
75+
compile("io.projectreactor:reactor-core:${version("reactor")}")
76+
compile("io.reactivex.rxjava2:rxjava:2.1.9")
77+
compile("com.github.akarnokd:rxjava2-extensions:0.20.8")
78+
79+
compile("org.openjdk.jmh:jmh-core:1.21")
80+
compile("com.typesafe.akka:akka-actor_2.12:2.5.0")
81+
compile(project(":kotlinx-coroutines-core"))
82+
83+
// add jmh dependency on main
84+
jmhImplementation(sourceSets.main.get().runtimeClasspath)
85+
}

benchmarks/src/main/kotlin/benchmarks/common/BenchmarkUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package benchmarks.common
66

77
import java.util.concurrent.*
88

9-
fun doGeomDistrWork(work: Int) {
9+
public fun doGeomDistrWork(work: Int) {
1010
// We use geometric distribution here. We also checked on macbook pro 13" (2017) that the resulting work times
1111
// are distributed geometrically, see https://github.com/Kotlin/kotlinx.coroutines/pull/1464#discussion_r355705325
1212
val p = 1.0 / work

build.gradle

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,11 @@ apply from: rootProject.file("gradle/experimental.gradle")
88
def rootModule = "kotlinx.coroutines"
99
def coreModule = "kotlinx-coroutines-core"
1010
// Not applicable for Kotlin plugin
11-
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom', 'publication-validator']
12-
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs', 'publication-validator']
11+
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom', 'integration-testing']
12+
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs', 'integration-testing']
1313
// Not published
1414
def unpublished = internal + ['example-frontend-js', 'android-unit-tests']
1515

16-
static def platformOf(project) {
17-
def name = project.name
18-
if (name.endsWith("-js")) return "js"
19-
if (name.endsWith("-common") || name.endsWith("-native")) {
20-
throw IllegalStateException("$name platform is not supported")
21-
}
22-
return "jvm"
23-
}
24-
2516
buildscript {
2617
/*
2718
* These property group is used to build kotlinx.coroutines against Kotlin compiler snapshot.
@@ -83,8 +74,6 @@ buildscript {
8374

8475
// JMH plugins
8576
classpath "com.github.jengelman.gradle.plugins:shadow:5.1.0"
86-
classpath "me.champeau.gradle:jmh-gradle-plugin:0.5.0-rc-2"
87-
classpath "net.ltgt.gradle:gradle-apt-plugin:0.21"
8877
}
8978
}
9079

@@ -166,7 +155,7 @@ allprojects {
166155
// Add dependency to core source sets. Core is configured in kx-core/build.gradle
167156
configure(subprojects.findAll { !sourceless.contains(it.name) && it.name != coreModule }) {
168157
evaluationDependsOn(":$coreModule")
169-
def platform = platformOf(it)
158+
def platform = PlatformKt.platformOf(it)
170159
apply from: rootProject.file("gradle/compile-${platform}.gradle")
171160
dependencies {
172161
// See comment below for rationale, it will be replaced with "project" dependency
@@ -227,7 +216,7 @@ if (build_snapshot_train) {
227216
* but publishing plugin does not re-read artifact names for kotlin-jvm projects, so renaming is not applied in pom files
228217
* for JVM-only projects.
229218
*
230-
* We artificially replace "project" dependency with "module" one to have proper names in pom files, but then substitute it
219+
* We artificially replace "project" dependency with "module" one to have proper names in pom files, but then substitute it
231220
* to have out "project" dependency back.
232221
*/
233222
configure(subprojects.findAll { it.name != coreModule && it.name != rootModule }) {
@@ -278,11 +267,8 @@ println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompi
278267
// --------------- Publish only from under JDK11+ ---------------
279268
task checkJdkForPublish {
280269
doFirst {
281-
String javaVersion = System.properties["java.version"]
282-
int i = javaVersion.indexOf('.')
283-
int javaVersionMajor = (i < 0 ? javaVersion : javaVersion.substring(0, i)).toInteger()
284-
if (javaVersionMajor < 11) {
285-
throw new GradleException("Project can be build for publishing only under JDK 11+, but found ${javaVersion}")
270+
if (JavaVersionKt.javaVersionMajor < 11) {
271+
throw new GradleException("Project can be build for publishing only under JDK 11+, but found ${JavaVersionKt.javaVersion}")
286272
}
287273
}
288274
}

0 commit comments

Comments
 (0)