You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ensure that flowOn does not resume downstream after cancellation
This is a problematic for Android when Main dispatcher is cancelled on destroyed activity. Atomic nature of the underlying channels is designed to prevent loss of elements, which is really not an issue for a typical application, but creates problem when used with channels.
This change introduces an optional `atomic` parameter to an internal `ReceiveChannel.receiveOrClosed` method to control cancellation atomicity of this function and tweaks `emitAll(ReceiveChannel)` implementation to abandon atomicity in favor of predictable cancellation.
Fixes#1265
Copy file name to clipboardExpand all lines: kotlinx-coroutines-core/api/kotlinx-coroutines-core.api
+6-1
Original file line number
Diff line number
Diff line change
@@ -537,6 +537,7 @@ public abstract interface class kotlinx/coroutines/channels/ActorScope : kotlinx
537
537
538
538
public final class kotlinx/coroutines/channels/ActorScope$DefaultImpls {
539
539
public static synthetic fun cancel (Lkotlinx/coroutines/channels/ActorScope;)V
540
+
public static synthetic fun receiveOrClosed (Lkotlinx/coroutines/channels/ActorScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
540
541
}
541
542
542
543
public abstract interface class kotlinx/coroutines/channels/BroadcastChannel : kotlinx/coroutines/channels/SendChannel {
@@ -572,6 +573,7 @@ public abstract interface class kotlinx/coroutines/channels/Channel : kotlinx/co
572
573
573
574
public final class kotlinx/coroutines/channels/Channel$DefaultImpls {
574
575
public static synthetic fun cancel (Lkotlinx/coroutines/channels/Channel;)V
576
+
public static synthetic fun receiveOrClosed (Lkotlinx/coroutines/channels/Channel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
575
577
}
576
578
577
579
public final class kotlinx/coroutines/channels/Channel$Factory {
@@ -768,14 +770,17 @@ public abstract interface class kotlinx/coroutines/channels/ReceiveChannel {
768
770
public abstract fun iterator ()Lkotlinx/coroutines/channels/ChannelIterator;
769
771
public abstract fun poll ()Ljava/lang/Object;
770
772
public abstract fun receive (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
771
-
public abstract fun receiveOrClosed (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
773
+
public abstract synthetic fun receiveOrClosed (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
774
+
public abstract fun receiveOrClosed (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
772
775
public abstract fun receiveOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
773
776
}
774
777
775
778
public final class kotlinx/coroutines/channels/ReceiveChannel$DefaultImpls {
776
779
public static synthetic fun cancel (Lkotlinx/coroutines/channels/ReceiveChannel;)V
777
780
public static synthetic fun cancel$default (Lkotlinx/coroutines/channels/ReceiveChannel;Ljava/lang/Throwable;ILjava/lang/Object;)Z
778
781
public static synthetic fun cancel$default (Lkotlinx/coroutines/channels/ReceiveChannel;Ljava/util/concurrent/CancellationException;ILjava/lang/Object;)V
782
+
public static synthetic fun receiveOrClosed (Lkotlinx/coroutines/channels/ReceiveChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
783
+
public static synthetic fun receiveOrClosed$default (Lkotlinx/coroutines/channels/ReceiveChannel;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
779
784
}
780
785
781
786
public abstract interface class kotlinx/coroutines/channels/SendChannel {
0 commit comments