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

1.4.0 experimentality #2316

Merged
merged 4 commits into from Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions benchmarks/src/jmh/kotlin/benchmarks/ChannelSinkBenchmark.kt
Expand Up @@ -50,4 +50,22 @@ open class ChannelSinkBenchmark {
for (i in start until (start + count))
send(i)
}

// Migrated from deprecated operators, are good only for stressing channels

private fun <E> ReceiveChannel<E>.filter(context: CoroutineContext = Dispatchers.Unconfined, predicate: suspend (E) -> Boolean): ReceiveChannel<E> =
GlobalScope.produce(context, onCompletion = { cancel() }) {
for (e in this@filter) {
if (predicate(e)) send(e)
}
}

private suspend inline fun <E, R> ReceiveChannel<E>.fold(initial: R, operation: (acc: R, E) -> R): R {
var accumulator = initial
consumeEach {
accumulator = operation(accumulator, it)
}
return accumulator
}
}

1 change: 0 additions & 1 deletion kotlinx-coroutines-core/api/kotlinx-coroutines-core.api
Expand Up @@ -989,7 +989,6 @@ public final class kotlinx/coroutines/flow/FlowKt {
public static final fun merge (Lkotlinx/coroutines/flow/Flow;)Lkotlinx/coroutines/flow/Flow;
public static final fun merge ([Lkotlinx/coroutines/flow/Flow;)Lkotlinx/coroutines/flow/Flow;
public static final fun observeOn (Lkotlinx/coroutines/flow/Flow;Lkotlin/coroutines/CoroutineContext;)Lkotlinx/coroutines/flow/Flow;
public static final synthetic fun onCompletion (Lkotlinx/coroutines/flow/Flow;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow;
public static final fun onCompletion (Lkotlinx/coroutines/flow/Flow;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/flow/Flow;
public static final fun onEach (Lkotlinx/coroutines/flow/Flow;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow;
public static final fun onEmpty (Lkotlinx/coroutines/flow/Flow;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow;
Expand Down
1 change: 0 additions & 1 deletion kotlinx-coroutines-core/common/src/Builders.common.kt
Expand Up @@ -175,7 +175,6 @@ public suspend fun <T> withContext(
*
* This inline function calls [withContext].
*/
@ExperimentalCoroutinesApi
public suspend inline operator fun <T> CoroutineDispatcher.invoke(
noinline block: suspend CoroutineScope.() -> T
): T = withContext(this, block)
Expand Down
1 change: 0 additions & 1 deletion kotlinx-coroutines-core/common/src/CompletableDeferred.kt
Expand Up @@ -57,7 +57,6 @@ public interface CompletableDeferred<T> : Deferred<T> {
* This function transitions this deferred in the same ways described by [CompletableDeferred.complete] and
* [CompletableDeferred.completeExceptionally].
*/
@ExperimentalCoroutinesApi // since 1.3.2, tentatively until 1.4.0
public fun <T> CompletableDeferred<T>.completeWith(result: Result<T>): Boolean =
result.fold({ complete(it) }, { completeExceptionally(it) })

Expand Down
4 changes: 2 additions & 2 deletions kotlinx-coroutines-core/common/src/CoroutineStart.kt
Expand Up @@ -55,7 +55,7 @@ public enum class CoroutineStart {
* Cancellability of coroutine at suspension points depends on the particular implementation details of
* suspending functions as in [DEFAULT].
*/
@ExperimentalCoroutinesApi
@ExperimentalCoroutinesApi // Since 1.0.0, no ETA on stability
ATOMIC,

/**
Expand All @@ -71,7 +71,7 @@ public enum class CoroutineStart {
*
* **Note: This is an experimental api.** Execution semantics of coroutines may change in the future when this mode is used.
*/
@ExperimentalCoroutinesApi
@ExperimentalCoroutinesApi // Since 1.0.0, no ETA on stability
qwwdfsad marked this conversation as resolved.
Show resolved Hide resolved
UNDISPATCHED;

/**
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/common/src/Debug.common.kt
Expand Up @@ -27,7 +27,7 @@ internal expect fun assert(value: () -> Boolean)
* Copy mechanism is used only on JVM, but it might be convenient to implement it in common exceptions,
* so on JVM their stacktraces will be properly recovered.
*/
@ExperimentalCoroutinesApi
@ExperimentalCoroutinesApi // Since 1.2.0, no ETA on stability

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is needed for CopyableThrowable to become stable? Is there any issue to watch? Can we help somehow?

This came to my attention, because Retrofit now produces not very helpful stacktraces from suspending calls and the corresponding fix is blocked because this is experimental: square/retrofit#3474

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best way is to let us know and file an issue. Filed #2367

public interface CopyableThrowable<T> where T : Throwable, T : CopyableThrowable<T> {

/**
Expand Down
1 change: 0 additions & 1 deletion kotlinx-coroutines-core/common/src/Delay.kt
Expand Up @@ -95,7 +95,6 @@ public interface Delay {
* }
* ```
*/
@ExperimentalCoroutinesApi
public suspend fun awaitCancellation(): Nothing = suspendCancellableCoroutine {}
qwwdfsad marked this conversation as resolved.
Show resolved Hide resolved

/**
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/common/src/channels/Broadcast.kt
Expand Up @@ -47,7 +47,7 @@ public fun <E> ReceiveChannel<E>.broadcast(
val scope = GlobalScope + Dispatchers.Unconfined + CoroutineExceptionHandler { _, _ -> }
// We can run this coroutine in the context that ignores all exceptions, because of `onCompletion = consume()`
// which passes all exceptions upstream to the source ReceiveChannel
return scope.broadcast(capacity = capacity, start = start, onCompletion = consumes()) {
return scope.broadcast(capacity = capacity, start = start, onCompletion = { cancelConsumed(it) }) {
for (e in this@broadcast) {
send(e)
}
Expand Down
Expand Up @@ -16,7 +16,6 @@ import kotlinx.coroutines.*
* * [DROP_LATEST] &mdash; drop **the latest** value that is being added to the buffer right now on buffer overflow
* (so that buffer contents stay the same), do not suspend.
*/
@ExperimentalCoroutinesApi
public enum class BufferOverflow {
/**
* Suspend on buffer overflow.
Expand Down