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
@@ -548,6 +548,7 @@ public abstract interface class kotlinx/coroutines/channels/ActorScope : kotlinx
548
548
549
549
public final class kotlinx/coroutines/channels/ActorScope$DefaultImpls {
550
550
public static synthetic fun cancel (Lkotlinx/coroutines/channels/ActorScope;)V
551
+
public static synthetic fun receiveOrClosed (Lkotlinx/coroutines/channels/ActorScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
551
552
}
552
553
553
554
public abstract interface class kotlinx/coroutines/channels/BroadcastChannel : kotlinx/coroutines/channels/SendChannel {
@@ -583,6 +584,7 @@ public abstract interface class kotlinx/coroutines/channels/Channel : kotlinx/co
583
584
584
585
public final class kotlinx/coroutines/channels/Channel$DefaultImpls {
585
586
public static synthetic fun cancel (Lkotlinx/coroutines/channels/Channel;)V
587
+
public static synthetic fun receiveOrClosed (Lkotlinx/coroutines/channels/Channel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
586
588
}
587
589
588
590
public final class kotlinx/coroutines/channels/Channel$Factory {
@@ -779,14 +781,17 @@ public abstract interface class kotlinx/coroutines/channels/ReceiveChannel {
779
781
public abstract fun iterator ()Lkotlinx/coroutines/channels/ChannelIterator;
780
782
public abstract fun poll ()Ljava/lang/Object;
781
783
public abstract fun receive (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
782
-
public abstract fun receiveOrClosed (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
784
+
public abstract synthetic fun receiveOrClosed (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
785
+
public abstract fun receiveOrClosed (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
783
786
public abstract fun receiveOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
784
787
}
785
788
786
789
public final class kotlinx/coroutines/channels/ReceiveChannel$DefaultImpls {
787
790
public static synthetic fun cancel (Lkotlinx/coroutines/channels/ReceiveChannel;)V
788
791
public static synthetic fun cancel$default (Lkotlinx/coroutines/channels/ReceiveChannel;Ljava/lang/Throwable;ILjava/lang/Object;)Z
789
792
public static synthetic fun cancel$default (Lkotlinx/coroutines/channels/ReceiveChannel;Ljava/util/concurrent/CancellationException;ILjava/lang/Object;)V
793
+
public static synthetic fun receiveOrClosed (Lkotlinx/coroutines/channels/ReceiveChannel;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
794
+
public static synthetic fun receiveOrClosed$default (Lkotlinx/coroutines/channels/ReceiveChannel;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
790
795
}
791
796
792
797
public abstract interface class kotlinx/coroutines/channels/SendChannel {
0 commit comments