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

Version 1.5.2 #2904

Merged
merged 22 commits into from Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
55aced2
Migrate from deprecated API and fix compilation warnings where possible
qwwdfsad Jul 13, 2021
2571516
Fix js tests (#2824)
qwwdfsad Jul 16, 2021
a3429f7
Introduce TestResult into TestBase as the first preparation step to m…
qwwdfsad Jul 16, 2021
3694ac9
More precise SharedFlow lint message (#2830)
qwwdfsad Jul 20, 2021
f85b207
Fixed a bug when onUndeliveredElement was invoked for normally-receiv…
qwwdfsad Jul 20, 2021
ea440c5
Make helpRemove actually lock-free and address multiple chained remov…
qwwdfsad Jul 27, 2021
bbd1335
Use setTimeout-based dispatcher on JS for ReactNative (#2846)
Legion2 Aug 2, 2021
8baa736
Migrate from deprecated API
qwwdfsad Aug 2, 2021
7e762d3
Optimize mutex implementation (#2851)
qwwdfsad Aug 2, 2021
3c29d96
Remove a duplicated word in the API doc of GlobalScope (#2874)
MasoodFallahpoor Aug 12, 2021
dfca05f
Fix typo in the deprecation message of BroadcastChannel<T>.asFlow()
qwwdfsad Aug 12, 2021
e123c8a
Minor documentation tweaks
qwwdfsad Aug 12, 2021
dabe24e
Add a missing 'is' in the API doc of Job (#2883)
MasoodFallahpoor Aug 17, 2021
3e89a17
Update binary compatibility validator to be compatible with upcoming …
qwwdfsad Aug 18, 2021
4508b13
Fix a mistake in the API doc of CoroutineScope (#2888)
MasoodFallahpoor Aug 23, 2021
810f28f
Verify that tests haven't written anything in the System.out (#2882)
qwwdfsad Aug 23, 2021
dbfb4ae
Fix the API doc of launchIn operator (#2893)
MasoodFallahpoor Aug 24, 2021
50807d0
Fix typo in the documentation of CompletableJob#complete (#2900)
pihanya Aug 26, 2021
dfa1b63
Update Kotlin (#2902)
qwwdfsad Aug 26, 2021
3dcc349
Make supervisor samples runnable (#2897)
qwwdfsad Aug 26, 2021
d3ead6f
Merge branch 'master' into develop
qwwdfsad Aug 26, 2021
45547c0
Version 1.5.2
qwwdfsad Aug 26, 2021
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: 10 additions & 0 deletions CHANGES.md
@@ -1,5 +1,15 @@
# Change log for kotlinx.coroutines

## Version 1.5.2

* Kotlin is updated to 1.5.30.
* New native targets for Apple Silicon are introduced.
* Fixed a bug when `onUndeliveredElement` was incorrectly called on a properly received elements on JS (#2826).
* Fixed `Dispatchers.Default` on React Native, it now fully relies on `setTimeout` instead of stub `process.nextTick`. Thanks to @Legion2 (#2843).
* Optimizations of `Mutex` implementation (#2581).
* `Mutex` implementation is made completely lock-free as stated (#2590).
* Various documentation and guides improvements. Thanks to @MasoodFallahpoor and @Pihanya.

## Version 1.5.1

* Atomic `update`, `getAndUpdate`, and `updateAndGet` operations of `MutableStateFlow` (#2720).
Expand Down
22 changes: 11 additions & 11 deletions README.md
Expand Up @@ -2,12 +2,12 @@

[![official JetBrains project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)
[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.1)](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.1/pom)
[![Kotlin](https://img.shields.io/badge/kotlin-1.5.20-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.2)](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.5.2/pom)
[![Kotlin](https://img.shields.io/badge/kotlin-1.5.30-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Slack channel](https://img.shields.io/badge/chat-slack-green.svg?logo=slack)](https://kotlinlang.slack.com/messages/coroutines/)

Library support for Kotlin coroutines with [multiplatform](#multiplatform) support.
This is a companion version for the Kotlin `1.5.20` release.
This is a companion version for the Kotlin `1.5.30` release.

```kotlin
suspend fun main() = coroutineScope {
Expand Down Expand Up @@ -83,15 +83,15 @@ Add dependencies (you can also add other modules that you need):
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>1.5.1</version>
<version>1.5.2</version>
</dependency>
```

And make sure that you use the latest Kotlin version:

```xml
<properties>
<kotlin.version>1.5.20</kotlin.version>
<kotlin.version>1.5.30</kotlin.version>
</properties>
```

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

```groovy
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
}
```

And make sure that you use the latest Kotlin version:

```groovy
buildscript {
ext.kotlin_version = '1.5.20'
ext.kotlin_version = '1.5.30'
}
```

Expand All @@ -127,7 +127,7 @@ Add dependencies (you can also add other modules that you need):

```groovy
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
}
```

Expand All @@ -147,7 +147,7 @@ Add [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android)
module as a dependency when using `kotlinx.coroutines` on Android:

```groovy
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
```

This gives you access to the Android [Dispatchers.Main]
Expand Down Expand Up @@ -180,7 +180,7 @@ In common code that should get compiled for different platforms, you can add a d
```groovy
commonMain {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
}
}
```
Expand All @@ -192,7 +192,7 @@ Platform-specific dependencies are recommended to be used only for non-multiplat
#### JS

Kotlin/JS version of `kotlinx.coroutines` is published as
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.5.1/jar)
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.5.2/jar)
(follow the link to get the dependency declaration snippet) and as [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) NPM package.

#### Native
Expand Down
9 changes: 9 additions & 0 deletions docs/topics/exception-handling.md
Expand Up @@ -364,6 +364,7 @@ only downwards. This can easily be demonstrated using the following example:
import kotlinx.coroutines.*

fun main() = runBlocking {
//sampleStart
val supervisor = SupervisorJob()
with(CoroutineScope(coroutineContext + supervisor)) {
// launch the first child -- its exception is ignored for this example (don't do this in practice!)
Expand All @@ -389,8 +390,10 @@ fun main() = runBlocking {
supervisor.cancel()
secondChild.join()
}
//sampleEnd
}
```
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}

> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-supervision-01.kt).
>
Expand Down Expand Up @@ -418,6 +421,7 @@ import kotlin.coroutines.*
import kotlinx.coroutines.*

fun main() = runBlocking {
//sampleStart
try {
supervisorScope {
val child = launch {
Expand All @@ -436,8 +440,10 @@ fun main() = runBlocking {
} catch(e: AssertionError) {
println("Caught an assertion error")
}
//sampleEnd
}
```
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}

> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-supervision-02.kt).
>
Expand Down Expand Up @@ -468,6 +474,7 @@ import kotlin.coroutines.*
import kotlinx.coroutines.*

fun main() = runBlocking {
//sampleStart
val handler = CoroutineExceptionHandler { _, exception ->
println("CoroutineExceptionHandler got $exception")
}
Expand All @@ -479,8 +486,10 @@ fun main() = runBlocking {
println("The scope is completing")
}
println("The scope is completed")
//sampleEnd
}
```
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}

> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-supervision-03.kt).
>
Expand Down
9 changes: 5 additions & 4 deletions gradle.properties
Expand Up @@ -3,14 +3,14 @@
#

# Kotlin
version=1.5.1-SNAPSHOT
version=1.5.2-SNAPSHOT
group=org.jetbrains.kotlinx
kotlin_version=1.5.20
kotlin_version=1.5.30

# Dependencies
junit_version=4.12
junit5_version=5.7.0
atomicfu_version=0.16.2
atomicfu_version=0.16.3
knit_version=0.3.0
html_version=0.7.2
lincheck_version=2.14
Expand All @@ -22,7 +22,7 @@ rxjava2_version=2.2.8
rxjava3_version=3.0.2
javafx_version=11.0.2
javafx_plugin_version=0.0.8
binary_compatibility_validator_version=0.6.0
binary_compatibility_validator_version=0.7.0
blockhound_version=1.0.2.RELEASE
jna_version=5.5.0

Expand Down Expand Up @@ -56,3 +56,4 @@ jekyll_version=4.0
org.gradle.jvmargs=-Xmx4g

kotlin.mpp.enableCompatibilityMetadataVariant=true
kotlin.mpp.stability.nowarn=true
4 changes: 4 additions & 0 deletions gradle/compile-native-multiplatform.gradle
Expand Up @@ -25,6 +25,10 @@ kotlin {
addTarget(presets.watchosArm64)
addTarget(presets.watchosX86)
addTarget(presets.watchosX64)
addTarget(presets.iosSimulatorArm64)
addTarget(presets.watchosSimulatorArm64)
addTarget(presets.tvosSimulatorArm64)
addTarget(presets.macosArm64)
}

sourceSets {
Expand Down
1 change: 1 addition & 0 deletions gradle/opt-in.gradle
Expand Up @@ -3,6 +3,7 @@
*/

ext.optInAnnotations = [
"kotlin.RequiresOptIn",
"kotlin.experimental.ExperimentalTypeInference",
"kotlin.ExperimentalMultiplatform",
"kotlinx.coroutines.DelicateCoroutinesApi",
Expand Down
4 changes: 4 additions & 0 deletions kotlinx-coroutines-core/common/src/CancellableContinuation.kt
Expand Up @@ -81,6 +81,10 @@ public interface CancellableContinuation<in T> : Continuation<T> {
* Same as [tryResume] but with [onCancellation] handler that called if and only if the value is not
* delivered to the caller because of the dispatch in the process, so that atomicity delivery
* guaranteed can be provided by having a cancellation fallback.
*
* Implementation note: current implementation always returns RESUME_TOKEN or `null`
*
* @suppress **This is unstable API and it is subject to change.**
*/
@InternalCoroutinesApi
public fun tryResume(value: T, idempotent: Any?, onCancellation: ((cause: Throwable) -> Unit)?): Any?
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/common/src/CompletableJob.kt
Expand Up @@ -21,7 +21,7 @@ public interface CompletableJob : Job {
*
* Subsequent invocations of this function have no effect and always produce `false`.
*
* This function transitions this job into _completed- state if it was not completed or cancelled yet.
* This function transitions this job into _completed_ state if it was not completed or cancelled yet.
* However, that if this job has children, then it transitions into _completing_ state and becomes _complete_
* once all its children are [complete][isCompleted]. See [Job] for details.
*/
Expand Down
4 changes: 2 additions & 2 deletions kotlinx-coroutines-core/common/src/CoroutineScope.kt
Expand Up @@ -49,7 +49,7 @@ import kotlin.coroutines.intrinsics.*
* * `CoroutineScope()` uses [Dispatchers.Default] for its coroutines.
* * `MainScope()` uses [Dispatchers.Main] for its coroutines.
*
* **The key part of custom usage of `CustomScope` is cancelling it and the end of the lifecycle.**
* **The key part of custom usage of `CustomScope` is cancelling it at the end of the lifecycle.**
* The [CoroutineScope.cancel] extension function shall be used when the entity that was launching coroutines
* is no longer needed. It cancels all the coroutines that might still be running on behalf of it.
*
Expand Down Expand Up @@ -185,7 +185,7 @@ public val CoroutineScope.isActive: Boolean
* }
* ```
*
* In top-level code, when launching a concurrent operation operation from a non-suspending context, an appropriately
* In top-level code, when launching a concurrent operation from a non-suspending context, an appropriately
* confined instance of [CoroutineScope] shall be used instead of a `GlobalScope`. See docs on [CoroutineScope] for
* details.
*
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/common/src/Job.kt
Expand Up @@ -168,7 +168,7 @@ public interface Job : CoroutineContext.Element {

/**
* Starts coroutine related to this job (if any) if it was not started yet.
* The result `true` if this invocation actually started coroutine or `false`
* The result is `true` if this invocation actually started coroutine or `false`
* if it was already started or completed.
*/
public fun start(): Boolean
Expand Down
Expand Up @@ -136,6 +136,7 @@ internal abstract class AbstractSendChannel<E>(
return sendSuspend(element)
}

@Suppress("DEPRECATION")
override fun offer(element: E): Boolean {
// Temporary migration for offer users who rely on onUndeliveredElement
try {
Expand Down
4 changes: 2 additions & 2 deletions kotlinx-coroutines-core/common/src/flow/Channels.kt
Expand Up @@ -171,7 +171,7 @@ private class ChannelAsFlow<T>(
*/
@Deprecated(
level = DeprecationLevel.WARNING,
message = "'BroadcastChannel' is obsolete and all coreresponding operators are deprecated " +
message = "'BroadcastChannel' is obsolete and all corresponding operators are deprecated " +
"in the favour of StateFlow and SharedFlow"
) // Since 1.5.0, was @FlowPreview, safe to remove in 1.7.0
public fun <T> BroadcastChannel<T>.asFlow(): Flow<T> = flow {
Expand All @@ -182,7 +182,7 @@ public fun <T> BroadcastChannel<T>.asFlow(): Flow<T> = flow {
* ### Deprecated
*
* **This API is deprecated.** The [BroadcastChannel] provides a complex channel-like API for hot flows.
* [SharedFlow] is a easier-to-use and more flow-centric API for the same purposes, so using
* [SharedFlow] is an easier-to-use and more flow-centric API for the same purposes, so using
* [shareIn] operator is preferred. It is not a direct replacement, so please
* study [shareIn] documentation to see what kind of shared flow fits your use-case. As a rule of thumb:
*
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/common/src/flow/SharedFlow.kt
Expand Up @@ -469,7 +469,7 @@ private class SharedFlowImpl<T>(
// outside of the lock: register dispose on cancellation
emitter?.let { cont.disposeOnCancellation(it) }
// outside of the lock: resume slots if needed
for (cont in resumes) cont?.resume(Unit)
for (r in resumes) r?.resume(Unit)
}

private fun cancelEmitter(emitter: Emitter) = synchronized(this) {
Expand Down
3 changes: 2 additions & 1 deletion kotlinx-coroutines-core/common/src/flow/operators/Lint.kt
Expand Up @@ -83,7 +83,8 @@ public val FlowCollector<*>.coroutineContext: CoroutineContext
get() = noImpl()

@Deprecated(
message = "SharedFlow never completes, so this operator has no effect.",
message = "SharedFlow never completes, so this operator typically has not effect, it can only " +
"catch exceptions from 'onSubscribe' operator",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("this")
)
Expand Down
Expand Up @@ -44,7 +44,7 @@ public suspend fun Flow<*>.collect(): Unit = collect(NopCollector)
* .launchIn(uiScope)
* ```
*
* Note that resulting value of [launchIn] is not used the provided scope takes care of cancellation.
* Note that the resulting value of [launchIn] is not used and the provided scope takes care of cancellation.
*/
public fun <T> Flow<T>.launchIn(scope: CoroutineScope): Job = scope.launch {
collect() // tail-call
Expand Down
Expand Up @@ -20,6 +20,7 @@ internal expect fun <E: Throwable> recoverStackTrace(exception: E, continuation:
/**
* initCause on JVM, nop on other platforms
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
internal expect fun Throwable.initCause(cause: Throwable)

/**
Expand Down