Files
rr3-apk/decompiled-community/sources/kotlinx/coroutines/channels/BufferedChannel.java
Daniel Elliott c080f0d97f Add Discord community version (64-bit only)
- Added realracing3-community.apk (71.57 MB)
- Removed 32-bit support (armeabi-v7a)
- Only includes arm64-v8a libraries
- Decompiled source code included
- Added README-community.md with analysis
2026-02-18 15:48:36 -08:00

2287 lines
110 KiB
Java

package kotlinx.coroutines.channels;
import androidx.concurrent.futures.AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0;
import com.amazonaws.handlers.HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0;
import java.util.ArrayList;
import java.util.concurrent.CancellationException;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import kotlin.ExceptionsKt__ExceptionsKt;
import kotlin.Result;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.DebugProbesKt;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.functions.Function3;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.CancellableContinuation;
import kotlinx.coroutines.CancellableContinuationImpl;
import kotlinx.coroutines.CancellableContinuationKt;
import kotlinx.coroutines.Waiter;
import kotlinx.coroutines.internal.ConcurrentLinkedListKt;
import kotlinx.coroutines.internal.ConcurrentLinkedListNode;
import kotlinx.coroutines.internal.InlineList;
import kotlinx.coroutines.internal.OnUndeliveredElementKt;
import kotlinx.coroutines.internal.Segment;
import kotlinx.coroutines.internal.SegmentOrClosed;
import kotlinx.coroutines.internal.StackTraceRecoveryKt;
import kotlinx.coroutines.internal.Symbol;
import kotlinx.coroutines.internal.UndeliveredElementException;
import kotlinx.coroutines.selects.SelectInstance;
/* loaded from: classes5.dex */
public class BufferedChannel implements Channel {
private volatile Object _closeCause;
private volatile long bufferEnd;
private volatile Object bufferEndSegment;
public final int capacity;
private volatile Object closeHandler;
private volatile long completedExpandBuffersAndPauseFlag;
public final Function1 onUndeliveredElement;
public final Function3 onUndeliveredElementReceiveCancellationConstructor;
private volatile Object receiveSegment;
private volatile long receivers;
private volatile Object sendSegment;
private volatile long sendersAndCloseStatus;
public static final AtomicLongFieldUpdater sendersAndCloseStatus$FU = AtomicLongFieldUpdater.newUpdater(BufferedChannel.class, "sendersAndCloseStatus");
public static final AtomicLongFieldUpdater receivers$FU = AtomicLongFieldUpdater.newUpdater(BufferedChannel.class, "receivers");
public static final AtomicLongFieldUpdater bufferEnd$FU = AtomicLongFieldUpdater.newUpdater(BufferedChannel.class, "bufferEnd");
public static final AtomicLongFieldUpdater completedExpandBuffersAndPauseFlag$FU = AtomicLongFieldUpdater.newUpdater(BufferedChannel.class, "completedExpandBuffersAndPauseFlag");
public static final AtomicReferenceFieldUpdater sendSegment$FU = AtomicReferenceFieldUpdater.newUpdater(BufferedChannel.class, Object.class, "sendSegment");
public static final AtomicReferenceFieldUpdater receiveSegment$FU = AtomicReferenceFieldUpdater.newUpdater(BufferedChannel.class, Object.class, "receiveSegment");
public static final AtomicReferenceFieldUpdater bufferEndSegment$FU = AtomicReferenceFieldUpdater.newUpdater(BufferedChannel.class, Object.class, "bufferEndSegment");
public static final AtomicReferenceFieldUpdater _closeCause$FU = AtomicReferenceFieldUpdater.newUpdater(BufferedChannel.class, Object.class, "_closeCause");
public static final AtomicReferenceFieldUpdater closeHandler$FU = AtomicReferenceFieldUpdater.newUpdater(BufferedChannel.class, Object.class, "closeHandler");
public boolean isConflatedDropOldest() {
return false;
}
public void onClosedIdempotent() {
}
public void onReceiveDequeued() {
}
public void onReceiveEnqueued() {
}
@Override // kotlinx.coroutines.channels.ReceiveChannel
public Object receive(Continuation continuation) {
return receive$suspendImpl(this, continuation);
}
@Override // kotlinx.coroutines.channels.ReceiveChannel
/* renamed from: receiveCatching-JP2dKIU, reason: not valid java name */
public Object mo4123receiveCatchingJP2dKIU(Continuation continuation) {
return m4122receiveCatchingJP2dKIU$suspendImpl(this, continuation);
}
@Override // kotlinx.coroutines.channels.SendChannel
public Object send(Object obj, Continuation continuation) {
return send$suspendImpl(this, obj, continuation);
}
public BufferedChannel(int i, Function1 function1) {
long initialBufferEnd;
Symbol symbol;
this.capacity = i;
this.onUndeliveredElement = function1;
if (i >= 0) {
initialBufferEnd = BufferedChannelKt.initialBufferEnd(i);
this.bufferEnd = initialBufferEnd;
this.completedExpandBuffersAndPauseFlag = getBufferEndCounter();
ChannelSegment channelSegment = new ChannelSegment(0L, null, this, 3);
this.sendSegment = channelSegment;
this.receiveSegment = channelSegment;
if (isRendezvousOrUnlimited()) {
channelSegment = BufferedChannelKt.NULL_SEGMENT;
Intrinsics.checkNotNull(channelSegment, "null cannot be cast to non-null type kotlinx.coroutines.channels.ChannelSegment<E of kotlinx.coroutines.channels.BufferedChannel>");
}
this.bufferEndSegment = channelSegment;
this.onUndeliveredElementReceiveCancellationConstructor = function1 != null ? new Function3() { // from class: kotlinx.coroutines.channels.BufferedChannel$onUndeliveredElementReceiveCancellationConstructor$1$1
{
super(3);
}
@Override // kotlin.jvm.functions.Function3
public /* bridge */ /* synthetic */ Object invoke(Object obj, Object obj2, Object obj3) {
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(obj);
return invoke((SelectInstance) null, obj2, obj3);
}
public final Function1 invoke(SelectInstance selectInstance, Object obj, Object obj2) {
return new Function1(obj2, BufferedChannel.this, selectInstance) { // from class: kotlinx.coroutines.channels.BufferedChannel$onUndeliveredElementReceiveCancellationConstructor$1$1.1
public final /* synthetic */ Object $element;
public final /* synthetic */ BufferedChannel this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Object invoke(Object obj3) {
invoke((Throwable) obj3);
return Unit.INSTANCE;
}
public final void invoke(Throwable th) {
if (this.$element == BufferedChannelKt.getCHANNEL_CLOSED()) {
return;
}
Function1 function12 = this.this$0.onUndeliveredElement;
throw null;
}
};
}
} : null;
symbol = BufferedChannelKt.NO_CLOSE_CAUSE;
this._closeCause = symbol;
return;
}
throw new IllegalArgumentException(("Invalid channel capacity: " + i + ", should be >=0").toString());
}
public final long getSendersCounter$kotlinx_coroutines_core() {
return sendersAndCloseStatus$FU.get(this) & 1152921504606846975L;
}
public final long getReceiversCounter$kotlinx_coroutines_core() {
return receivers$FU.get(this);
}
public final long getBufferEndCounter() {
return bufferEnd$FU.get(this);
}
public final boolean isRendezvousOrUnlimited() {
long bufferEndCounter = getBufferEndCounter();
return bufferEndCounter == 0 || bufferEndCounter == Long.MAX_VALUE;
}
public static /* synthetic */ Object send$suspendImpl(BufferedChannel bufferedChannel, Object obj, Continuation continuation) {
ChannelSegment channelSegment;
Object coroutine_suspended;
Object coroutine_suspended2;
Object coroutine_suspended3;
Object coroutine_suspended4;
ChannelSegment channelSegment2 = (ChannelSegment) sendSegment$FU.get(bufferedChannel);
while (true) {
long andIncrement = sendersAndCloseStatus$FU.getAndIncrement(bufferedChannel);
long j = andIncrement & 1152921504606846975L;
boolean isClosedForSend0 = bufferedChannel.isClosedForSend0(andIncrement);
int i = BufferedChannelKt.SEGMENT_SIZE;
long j2 = j / i;
int i2 = (int) (j % i);
if (channelSegment2.id != j2) {
ChannelSegment findSegmentSend = bufferedChannel.findSegmentSend(j2, channelSegment2);
if (findSegmentSend != null) {
channelSegment = findSegmentSend;
} else if (isClosedForSend0) {
Object onClosedSend = bufferedChannel.onClosedSend(obj, continuation);
coroutine_suspended4 = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (onClosedSend == coroutine_suspended4) {
return onClosedSend;
}
}
} else {
channelSegment = channelSegment2;
}
int updateCellSend = bufferedChannel.updateCellSend(channelSegment, i2, obj, j, null, isClosedForSend0);
if (updateCellSend == 0) {
channelSegment.cleanPrev();
break;
}
if (updateCellSend == 1) {
break;
}
if (updateCellSend != 2) {
if (updateCellSend == 3) {
Object sendOnNoWaiterSuspend = bufferedChannel.sendOnNoWaiterSuspend(channelSegment, i2, obj, j, continuation);
coroutine_suspended2 = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (sendOnNoWaiterSuspend == coroutine_suspended2) {
return sendOnNoWaiterSuspend;
}
} else if (updateCellSend != 4) {
if (updateCellSend == 5) {
channelSegment.cleanPrev();
}
channelSegment2 = channelSegment;
} else {
if (j < bufferedChannel.getReceiversCounter$kotlinx_coroutines_core()) {
channelSegment.cleanPrev();
}
Object onClosedSend2 = bufferedChannel.onClosedSend(obj, continuation);
coroutine_suspended3 = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (onClosedSend2 == coroutine_suspended3) {
return onClosedSend2;
}
}
} else if (isClosedForSend0) {
channelSegment.onSlotCleaned();
Object onClosedSend3 = bufferedChannel.onClosedSend(obj, continuation);
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (onClosedSend3 == coroutine_suspended) {
return onClosedSend3;
}
}
}
return Unit.INSTANCE;
}
public final void prepareSenderForSuspension(Waiter waiter, ChannelSegment channelSegment, int i) {
waiter.invokeOnCancellation(channelSegment, i + BufferedChannelKt.SEGMENT_SIZE);
}
public final void onClosedSendOnNoWaiterSuspend(Object obj, CancellableContinuation cancellableContinuation) {
Function1 function1 = this.onUndeliveredElement;
if (function1 != null) {
OnUndeliveredElementKt.callUndeliveredElement(function1, obj, cancellableContinuation.getContext());
}
Throwable sendException = getSendException();
Result.Companion companion = Result.Companion;
cancellableContinuation.resumeWith(Result.m4060constructorimpl(ResultKt.createFailure(sendException)));
}
/* JADX WARN: Code restructure failed: missing block: B:51:?, code lost:
return kotlinx.coroutines.channels.ChannelResult.Companion.m4139successJP2dKIU(kotlin.Unit.INSTANCE);
*/
@Override // kotlinx.coroutines.channels.SendChannel
/* renamed from: trySend-JP2dKIU, reason: not valid java name */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public java.lang.Object mo4126trySendJP2dKIU(java.lang.Object r15) {
/*
r14 = this;
java.util.concurrent.atomic.AtomicLongFieldUpdater r0 = kotlinx.coroutines.channels.BufferedChannel.sendersAndCloseStatus$FU
long r0 = r0.get(r14)
boolean r0 = r14.shouldSendSuspend(r0)
if (r0 == 0) goto L13
kotlinx.coroutines.channels.ChannelResult$Companion r15 = kotlinx.coroutines.channels.ChannelResult.Companion
java.lang.Object r15 = r15.m4138failurePtdJZtk()
return r15
L13:
kotlinx.coroutines.internal.Symbol r8 = kotlinx.coroutines.channels.BufferedChannelKt.access$getINTERRUPTED_SEND$p()
java.util.concurrent.atomic.AtomicReferenceFieldUpdater r0 = access$getSendSegment$FU$p()
java.lang.Object r0 = r0.get(r14)
kotlinx.coroutines.channels.ChannelSegment r0 = (kotlinx.coroutines.channels.ChannelSegment) r0
L21:
java.util.concurrent.atomic.AtomicLongFieldUpdater r1 = access$getSendersAndCloseStatus$FU$p()
long r1 = r1.getAndIncrement(r14)
r3 = 1152921504606846975(0xfffffffffffffff, double:1.2882297539194265E-231)
long r9 = r1 & r3
boolean r11 = access$isClosedForSend0(r14, r1)
int r1 = kotlinx.coroutines.channels.BufferedChannelKt.SEGMENT_SIZE
long r2 = (long) r1
long r2 = r9 / r2
long r4 = (long) r1
long r4 = r9 % r4
int r12 = (int) r4
long r4 = r0.id
int r1 = (r4 > r2 ? 1 : (r4 == r2 ? 0 : -1))
if (r1 == 0) goto L59
kotlinx.coroutines.channels.ChannelSegment r1 = access$findSegmentSend(r14, r2, r0)
if (r1 != 0) goto L57
if (r11 == 0) goto L21
L4b:
kotlinx.coroutines.channels.ChannelResult$Companion r15 = kotlinx.coroutines.channels.ChannelResult.Companion
java.lang.Throwable r0 = r14.getSendException()
java.lang.Object r15 = r15.m4137closedJP2dKIU(r0)
goto Lbe
L57:
r13 = r1
goto L5a
L59:
r13 = r0
L5a:
r0 = r14
r1 = r13
r2 = r12
r3 = r15
r4 = r9
r6 = r8
r7 = r11
int r0 = access$updateCellSend(r0, r1, r2, r3, r4, r6, r7)
if (r0 == 0) goto Lba
r1 = 1
if (r0 == r1) goto Lb1
r1 = 2
if (r0 == r1) goto L94
r1 = 3
if (r0 == r1) goto L88
r1 = 4
if (r0 == r1) goto L7c
r1 = 5
if (r0 == r1) goto L77
goto L7a
L77:
r13.cleanPrev()
L7a:
r0 = r13
goto L21
L7c:
long r0 = r14.getReceiversCounter$kotlinx_coroutines_core()
int r15 = (r9 > r0 ? 1 : (r9 == r0 ? 0 : -1))
if (r15 >= 0) goto L4b
r13.cleanPrev()
goto L4b
L88:
java.lang.IllegalStateException r15 = new java.lang.IllegalStateException
java.lang.String r0 = "unexpected"
java.lang.String r0 = r0.toString()
r15.<init>(r0)
throw r15
L94:
if (r11 == 0) goto L9a
r13.onSlotCleaned()
goto L4b
L9a:
boolean r15 = r8 instanceof kotlinx.coroutines.Waiter
if (r15 == 0) goto La1
kotlinx.coroutines.Waiter r8 = (kotlinx.coroutines.Waiter) r8
goto La2
La1:
r8 = 0
La2:
if (r8 == 0) goto La7
access$prepareSenderForSuspension(r14, r8, r13, r12)
La7:
r13.onSlotCleaned()
kotlinx.coroutines.channels.ChannelResult$Companion r15 = kotlinx.coroutines.channels.ChannelResult.Companion
java.lang.Object r15 = r15.m4138failurePtdJZtk()
goto Lbe
Lb1:
kotlinx.coroutines.channels.ChannelResult$Companion r15 = kotlinx.coroutines.channels.ChannelResult.Companion
kotlin.Unit r0 = kotlin.Unit.INSTANCE
java.lang.Object r15 = r15.m4139successJP2dKIU(r0)
goto Lbe
Lba:
r13.cleanPrev()
goto Lb1
Lbe:
return r15
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.channels.BufferedChannel.mo4126trySendJP2dKIU(java.lang.Object):java.lang.Object");
}
public final Object onClosedSend(Object obj, Continuation continuation) {
Continuation intercepted;
Object coroutine_suspended;
Object coroutine_suspended2;
UndeliveredElementException callUndeliveredElementCatchingException$default;
intercepted = IntrinsicsKt__IntrinsicsJvmKt.intercepted(continuation);
CancellableContinuationImpl cancellableContinuationImpl = new CancellableContinuationImpl(intercepted, 1);
cancellableContinuationImpl.initCancellability();
Function1 function1 = this.onUndeliveredElement;
if (function1 != null && (callUndeliveredElementCatchingException$default = OnUndeliveredElementKt.callUndeliveredElementCatchingException$default(function1, obj, null, 2, null)) != null) {
ExceptionsKt__ExceptionsKt.addSuppressed(callUndeliveredElementCatchingException$default, getSendException());
Result.Companion companion = Result.Companion;
cancellableContinuationImpl.resumeWith(Result.m4060constructorimpl(ResultKt.createFailure(callUndeliveredElementCatchingException$default)));
} else {
Throwable sendException = getSendException();
Result.Companion companion2 = Result.Companion;
cancellableContinuationImpl.resumeWith(Result.m4060constructorimpl(ResultKt.createFailure(sendException)));
}
Object result = cancellableContinuationImpl.getResult();
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (result == coroutine_suspended) {
DebugProbesKt.probeCoroutineSuspended(continuation);
}
coroutine_suspended2 = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
return result == coroutine_suspended2 ? result : Unit.INSTANCE;
}
public final class BufferedChannelIterator implements ChannelIterator, Waiter {
public CancellableContinuationImpl continuation;
public Object receiveResult;
public final Object hasNextOnNoWaiterSuspend(ChannelSegment channelSegment, int i, long j, Continuation continuation) {
Continuation intercepted;
Symbol symbol;
Symbol symbol2;
Boolean boxBoolean;
Symbol symbol3;
Symbol symbol4;
Symbol symbol5;
Object coroutine_suspended;
BufferedChannel bufferedChannel = BufferedChannel.this;
intercepted = IntrinsicsKt__IntrinsicsJvmKt.intercepted(continuation);
CancellableContinuationImpl orCreateCancellableContinuation = CancellableContinuationKt.getOrCreateCancellableContinuation(intercepted);
try {
this.continuation = orCreateCancellableContinuation;
Object updateCellReceive = bufferedChannel.updateCellReceive(channelSegment, i, j, this);
symbol = BufferedChannelKt.SUSPEND;
if (updateCellReceive == symbol) {
bufferedChannel.prepareReceiverForSuspension(this, channelSegment, i);
} else {
symbol2 = BufferedChannelKt.FAILED;
Function1 function1 = null;
if (updateCellReceive == symbol2) {
if (j < bufferedChannel.getSendersCounter$kotlinx_coroutines_core()) {
channelSegment.cleanPrev();
}
ChannelSegment channelSegment2 = (ChannelSegment) BufferedChannel.receiveSegment$FU.get(bufferedChannel);
while (true) {
if (!bufferedChannel.isClosedForReceive()) {
long andIncrement = BufferedChannel.receivers$FU.getAndIncrement(bufferedChannel);
int i2 = BufferedChannelKt.SEGMENT_SIZE;
long j2 = andIncrement / i2;
int i3 = (int) (andIncrement % i2);
if (channelSegment2.id != j2) {
ChannelSegment findSegmentReceive = bufferedChannel.findSegmentReceive(j2, channelSegment2);
if (findSegmentReceive != null) {
channelSegment2 = findSegmentReceive;
}
}
Object updateCellReceive2 = bufferedChannel.updateCellReceive(channelSegment2, i3, andIncrement, this);
symbol3 = BufferedChannelKt.SUSPEND;
if (updateCellReceive2 == symbol3) {
bufferedChannel.prepareReceiverForSuspension(this, channelSegment2, i3);
break;
}
symbol4 = BufferedChannelKt.FAILED;
if (updateCellReceive2 != symbol4) {
symbol5 = BufferedChannelKt.SUSPEND_NO_WAITER;
if (updateCellReceive2 == symbol5) {
throw new IllegalStateException("unexpected".toString());
}
channelSegment2.cleanPrev();
this.receiveResult = updateCellReceive2;
this.continuation = null;
boxBoolean = Boxing.boxBoolean(true);
Function1 function12 = bufferedChannel.onUndeliveredElement;
if (function12 != null) {
function1 = OnUndeliveredElementKt.bindCancellationFun(function12, updateCellReceive2, orCreateCancellableContinuation.getContext());
}
} else if (andIncrement < bufferedChannel.getSendersCounter$kotlinx_coroutines_core()) {
channelSegment2.cleanPrev();
}
} else {
onClosedHasNextNoWaiterSuspend();
break;
}
}
} else {
channelSegment.cleanPrev();
this.receiveResult = updateCellReceive;
this.continuation = null;
boxBoolean = Boxing.boxBoolean(true);
Function1 function13 = bufferedChannel.onUndeliveredElement;
if (function13 != null) {
function1 = OnUndeliveredElementKt.bindCancellationFun(function13, updateCellReceive, orCreateCancellableContinuation.getContext());
}
}
orCreateCancellableContinuation.resume(boxBoolean, function1);
}
Object result = orCreateCancellableContinuation.getResult();
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (result == coroutine_suspended) {
DebugProbesKt.probeCoroutineSuspended(continuation);
}
return result;
} catch (Throwable th) {
orCreateCancellableContinuation.releaseClaimedReusableContinuation$kotlinx_coroutines_core();
throw th;
}
}
public BufferedChannelIterator() {
Symbol symbol;
symbol = BufferedChannelKt.NO_RECEIVE_RESULT;
this.receiveResult = symbol;
}
@Override // kotlinx.coroutines.channels.ChannelIterator
public Object hasNext(Continuation continuation) {
ChannelSegment channelSegment;
Symbol symbol;
Symbol symbol2;
Symbol symbol3;
BufferedChannel bufferedChannel = BufferedChannel.this;
ChannelSegment channelSegment2 = (ChannelSegment) BufferedChannel.receiveSegment$FU.get(bufferedChannel);
while (!bufferedChannel.isClosedForReceive()) {
long andIncrement = BufferedChannel.receivers$FU.getAndIncrement(bufferedChannel);
int i = BufferedChannelKt.SEGMENT_SIZE;
long j = andIncrement / i;
int i2 = (int) (andIncrement % i);
if (channelSegment2.id != j) {
ChannelSegment findSegmentReceive = bufferedChannel.findSegmentReceive(j, channelSegment2);
if (findSegmentReceive == null) {
continue;
} else {
channelSegment = findSegmentReceive;
}
} else {
channelSegment = channelSegment2;
}
Object updateCellReceive = bufferedChannel.updateCellReceive(channelSegment, i2, andIncrement, null);
symbol = BufferedChannelKt.SUSPEND;
if (updateCellReceive == symbol) {
throw new IllegalStateException("unreachable".toString());
}
symbol2 = BufferedChannelKt.FAILED;
if (updateCellReceive != symbol2) {
symbol3 = BufferedChannelKt.SUSPEND_NO_WAITER;
if (updateCellReceive != symbol3) {
channelSegment.cleanPrev();
this.receiveResult = updateCellReceive;
return Boxing.boxBoolean(true);
}
return hasNextOnNoWaiterSuspend(channelSegment, i2, andIncrement, continuation);
}
if (andIncrement < bufferedChannel.getSendersCounter$kotlinx_coroutines_core()) {
channelSegment.cleanPrev();
}
channelSegment2 = channelSegment;
}
return Boxing.boxBoolean(onClosedHasNext());
}
public final boolean onClosedHasNext() {
this.receiveResult = BufferedChannelKt.getCHANNEL_CLOSED();
Throwable closeCause = BufferedChannel.this.getCloseCause();
if (closeCause == null) {
return false;
}
throw StackTraceRecoveryKt.recoverStackTrace(closeCause);
}
@Override // kotlinx.coroutines.Waiter
public void invokeOnCancellation(Segment segment, int i) {
CancellableContinuationImpl cancellableContinuationImpl = this.continuation;
if (cancellableContinuationImpl != null) {
cancellableContinuationImpl.invokeOnCancellation(segment, i);
}
}
public final void onClosedHasNextNoWaiterSuspend() {
CancellableContinuationImpl cancellableContinuationImpl = this.continuation;
Intrinsics.checkNotNull(cancellableContinuationImpl);
this.continuation = null;
this.receiveResult = BufferedChannelKt.getCHANNEL_CLOSED();
Throwable closeCause = BufferedChannel.this.getCloseCause();
if (closeCause == null) {
Result.Companion companion = Result.Companion;
cancellableContinuationImpl.resumeWith(Result.m4060constructorimpl(Boolean.FALSE));
} else {
Result.Companion companion2 = Result.Companion;
cancellableContinuationImpl.resumeWith(Result.m4060constructorimpl(ResultKt.createFailure(closeCause)));
}
}
@Override // kotlinx.coroutines.channels.ChannelIterator
public Object next() {
Symbol symbol;
Symbol symbol2;
Object obj = this.receiveResult;
symbol = BufferedChannelKt.NO_RECEIVE_RESULT;
if (obj == symbol) {
throw new IllegalStateException("`hasNext()` has not been invoked".toString());
}
symbol2 = BufferedChannelKt.NO_RECEIVE_RESULT;
this.receiveResult = symbol2;
if (obj != BufferedChannelKt.getCHANNEL_CLOSED()) {
return obj;
}
throw StackTraceRecoveryKt.recoverStackTrace(BufferedChannel.this.getReceiveException());
}
public final boolean tryResumeHasNext(Object obj) {
boolean tryResume0;
CancellableContinuationImpl cancellableContinuationImpl = this.continuation;
Intrinsics.checkNotNull(cancellableContinuationImpl);
this.continuation = null;
this.receiveResult = obj;
Boolean bool = Boolean.TRUE;
Function1 function1 = BufferedChannel.this.onUndeliveredElement;
tryResume0 = BufferedChannelKt.tryResume0(cancellableContinuationImpl, bool, function1 != null ? OnUndeliveredElementKt.bindCancellationFun(function1, obj, cancellableContinuationImpl.getContext()) : null);
return tryResume0;
}
public final void tryResumeHasNextOnClosedChannel() {
CancellableContinuationImpl cancellableContinuationImpl = this.continuation;
Intrinsics.checkNotNull(cancellableContinuationImpl);
this.continuation = null;
this.receiveResult = BufferedChannelKt.getCHANNEL_CLOSED();
Throwable closeCause = BufferedChannel.this.getCloseCause();
if (closeCause == null) {
Result.Companion companion = Result.Companion;
cancellableContinuationImpl.resumeWith(Result.m4060constructorimpl(Boolean.FALSE));
} else {
Result.Companion companion2 = Result.Companion;
cancellableContinuationImpl.resumeWith(Result.m4060constructorimpl(ResultKt.createFailure(closeCause)));
}
}
}
public final Object receiveOnNoWaiterSuspend(ChannelSegment channelSegment, int i, long j, Continuation continuation) {
Continuation intercepted;
Symbol symbol;
Symbol symbol2;
Symbol symbol3;
Symbol symbol4;
Symbol symbol5;
Object coroutine_suspended;
intercepted = IntrinsicsKt__IntrinsicsJvmKt.intercepted(continuation);
CancellableContinuationImpl orCreateCancellableContinuation = CancellableContinuationKt.getOrCreateCancellableContinuation(intercepted);
try {
Object updateCellReceive = updateCellReceive(channelSegment, i, j, orCreateCancellableContinuation);
symbol = BufferedChannelKt.SUSPEND;
if (updateCellReceive == symbol) {
prepareReceiverForSuspension(orCreateCancellableContinuation, channelSegment, i);
} else {
symbol2 = BufferedChannelKt.FAILED;
Function1 function1 = null;
function1 = null;
if (updateCellReceive == symbol2) {
if (j < getSendersCounter$kotlinx_coroutines_core()) {
channelSegment.cleanPrev();
}
ChannelSegment channelSegment2 = (ChannelSegment) receiveSegment$FU.get(this);
while (true) {
if (isClosedForReceive()) {
onClosedReceiveOnNoWaiterSuspend(orCreateCancellableContinuation);
break;
}
long andIncrement = receivers$FU.getAndIncrement(this);
int i2 = BufferedChannelKt.SEGMENT_SIZE;
long j2 = andIncrement / i2;
int i3 = (int) (andIncrement % i2);
if (channelSegment2.id != j2) {
ChannelSegment findSegmentReceive = findSegmentReceive(j2, channelSegment2);
if (findSegmentReceive != null) {
channelSegment2 = findSegmentReceive;
}
}
updateCellReceive = updateCellReceive(channelSegment2, i3, andIncrement, orCreateCancellableContinuation);
symbol3 = BufferedChannelKt.SUSPEND;
if (updateCellReceive == symbol3) {
CancellableContinuationImpl cancellableContinuationImpl = orCreateCancellableContinuation instanceof Waiter ? orCreateCancellableContinuation : null;
if (cancellableContinuationImpl != null) {
prepareReceiverForSuspension(cancellableContinuationImpl, channelSegment2, i3);
}
} else {
symbol4 = BufferedChannelKt.FAILED;
if (updateCellReceive != symbol4) {
symbol5 = BufferedChannelKt.SUSPEND_NO_WAITER;
if (updateCellReceive == symbol5) {
throw new IllegalStateException("unexpected".toString());
}
channelSegment2.cleanPrev();
Function1 function12 = this.onUndeliveredElement;
if (function12 != null) {
function1 = OnUndeliveredElementKt.bindCancellationFun(function12, updateCellReceive, orCreateCancellableContinuation.getContext());
}
} else if (andIncrement < getSendersCounter$kotlinx_coroutines_core()) {
channelSegment2.cleanPrev();
}
}
}
} else {
channelSegment.cleanPrev();
Function1 function13 = this.onUndeliveredElement;
if (function13 != null) {
function1 = OnUndeliveredElementKt.bindCancellationFun(function13, updateCellReceive, orCreateCancellableContinuation.getContext());
}
}
orCreateCancellableContinuation.resume(updateCellReceive, function1);
}
Object result = orCreateCancellableContinuation.getResult();
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (result == coroutine_suspended) {
DebugProbesKt.probeCoroutineSuspended(continuation);
}
return result;
} catch (Throwable th) {
orCreateCancellableContinuation.releaseClaimedReusableContinuation$kotlinx_coroutines_core();
throw th;
}
}
/* JADX WARN: Removed duplicated region for block: B:39:0x011c */
/* JADX WARN: Removed duplicated region for block: B:42:0x0125 A[RETURN] */
/* JADX WARN: Removed duplicated region for block: B:44:0x0126 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final java.lang.Object sendOnNoWaiterSuspend(kotlinx.coroutines.channels.ChannelSegment r21, int r22, java.lang.Object r23, long r24, kotlin.coroutines.Continuation r26) {
/*
Method dump skipped, instructions count: 301
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.channels.BufferedChannel.sendOnNoWaiterSuspend(kotlinx.coroutines.channels.ChannelSegment, int, java.lang.Object, long, kotlin.coroutines.Continuation):java.lang.Object");
}
public final int updateCellSend(ChannelSegment channelSegment, int i, Object obj, long j, Object obj2, boolean z) {
Symbol symbol;
Symbol symbol2;
Symbol symbol3;
channelSegment.storeElement$kotlinx_coroutines_core(i, obj);
if (z) {
return updateCellSendSlow(channelSegment, i, obj, j, obj2, z);
}
Object state$kotlinx_coroutines_core = channelSegment.getState$kotlinx_coroutines_core(i);
if (state$kotlinx_coroutines_core == null) {
if (bufferOrRendezvousSend(j)) {
if (channelSegment.casState$kotlinx_coroutines_core(i, null, BufferedChannelKt.BUFFERED)) {
return 1;
}
} else {
if (obj2 == null) {
return 3;
}
if (channelSegment.casState$kotlinx_coroutines_core(i, null, obj2)) {
return 2;
}
}
} else if (state$kotlinx_coroutines_core instanceof Waiter) {
channelSegment.cleanElement$kotlinx_coroutines_core(i);
if (tryResumeReceiver(state$kotlinx_coroutines_core, obj)) {
symbol3 = BufferedChannelKt.DONE_RCV;
channelSegment.setState$kotlinx_coroutines_core(i, symbol3);
onReceiveDequeued();
return 0;
}
symbol = BufferedChannelKt.INTERRUPTED_RCV;
Object andSetState$kotlinx_coroutines_core = channelSegment.getAndSetState$kotlinx_coroutines_core(i, symbol);
symbol2 = BufferedChannelKt.INTERRUPTED_RCV;
if (andSetState$kotlinx_coroutines_core != symbol2) {
channelSegment.onCancelledRequest(i, true);
}
return 5;
}
return updateCellSendSlow(channelSegment, i, obj, j, obj2, z);
}
public final int updateCellSendSlow(ChannelSegment channelSegment, int i, Object obj, long j, Object obj2, boolean z) {
Symbol symbol;
Symbol symbol2;
Symbol symbol3;
Symbol symbol4;
Symbol symbol5;
Symbol symbol6;
Symbol symbol7;
while (true) {
Object state$kotlinx_coroutines_core = channelSegment.getState$kotlinx_coroutines_core(i);
if (state$kotlinx_coroutines_core == null) {
if (!bufferOrRendezvousSend(j) || z) {
if (z) {
symbol = BufferedChannelKt.INTERRUPTED_SEND;
if (channelSegment.casState$kotlinx_coroutines_core(i, null, symbol)) {
channelSegment.onCancelledRequest(i, false);
return 4;
}
} else {
if (obj2 == null) {
return 3;
}
if (channelSegment.casState$kotlinx_coroutines_core(i, null, obj2)) {
return 2;
}
}
} else if (channelSegment.casState$kotlinx_coroutines_core(i, null, BufferedChannelKt.BUFFERED)) {
return 1;
}
} else {
symbol2 = BufferedChannelKt.IN_BUFFER;
if (state$kotlinx_coroutines_core == symbol2) {
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, BufferedChannelKt.BUFFERED)) {
return 1;
}
} else {
symbol3 = BufferedChannelKt.INTERRUPTED_RCV;
if (state$kotlinx_coroutines_core == symbol3) {
channelSegment.cleanElement$kotlinx_coroutines_core(i);
return 5;
}
symbol4 = BufferedChannelKt.POISONED;
if (state$kotlinx_coroutines_core == symbol4) {
channelSegment.cleanElement$kotlinx_coroutines_core(i);
return 5;
}
if (state$kotlinx_coroutines_core == BufferedChannelKt.getCHANNEL_CLOSED()) {
channelSegment.cleanElement$kotlinx_coroutines_core(i);
completeCloseOrCancel();
return 4;
}
channelSegment.cleanElement$kotlinx_coroutines_core(i);
if (state$kotlinx_coroutines_core instanceof WaiterEB) {
state$kotlinx_coroutines_core = ((WaiterEB) state$kotlinx_coroutines_core).waiter;
}
if (tryResumeReceiver(state$kotlinx_coroutines_core, obj)) {
symbol7 = BufferedChannelKt.DONE_RCV;
channelSegment.setState$kotlinx_coroutines_core(i, symbol7);
onReceiveDequeued();
return 0;
}
symbol5 = BufferedChannelKt.INTERRUPTED_RCV;
Object andSetState$kotlinx_coroutines_core = channelSegment.getAndSetState$kotlinx_coroutines_core(i, symbol5);
symbol6 = BufferedChannelKt.INTERRUPTED_RCV;
if (andSetState$kotlinx_coroutines_core != symbol6) {
channelSegment.onCancelledRequest(i, true);
}
return 5;
}
}
}
}
public final boolean shouldSendSuspend(long j) {
if (isClosedForSend0(j)) {
return false;
}
return !bufferOrRendezvousSend(j & 1152921504606846975L);
}
public final boolean bufferOrRendezvousSend(long j) {
return j < getBufferEndCounter() || j < getReceiversCounter$kotlinx_coroutines_core() + ((long) this.capacity);
}
public final boolean tryResumeReceiver(Object obj, Object obj2) {
boolean tryResume0;
boolean tryResume02;
if (obj instanceof ReceiveCatching) {
Intrinsics.checkNotNull(obj, "null cannot be cast to non-null type kotlinx.coroutines.channels.ReceiveCatching<E of kotlinx.coroutines.channels.BufferedChannel>");
ReceiveCatching receiveCatching = (ReceiveCatching) obj;
CancellableContinuationImpl cancellableContinuationImpl = receiveCatching.cont;
ChannelResult m4127boximpl = ChannelResult.m4127boximpl(ChannelResult.Companion.m4139successJP2dKIU(obj2));
Function1 function1 = this.onUndeliveredElement;
tryResume02 = BufferedChannelKt.tryResume0(cancellableContinuationImpl, m4127boximpl, function1 != null ? OnUndeliveredElementKt.bindCancellationFun(function1, obj2, receiveCatching.cont.getContext()) : null);
return tryResume02;
}
if (obj instanceof BufferedChannelIterator) {
Intrinsics.checkNotNull(obj, "null cannot be cast to non-null type kotlinx.coroutines.channels.BufferedChannel.BufferedChannelIterator<E of kotlinx.coroutines.channels.BufferedChannel>");
return ((BufferedChannelIterator) obj).tryResumeHasNext(obj2);
}
if (obj instanceof CancellableContinuation) {
Intrinsics.checkNotNull(obj, "null cannot be cast to non-null type kotlinx.coroutines.CancellableContinuation<E of kotlinx.coroutines.channels.BufferedChannel>");
CancellableContinuation cancellableContinuation = (CancellableContinuation) obj;
Function1 function12 = this.onUndeliveredElement;
tryResume0 = BufferedChannelKt.tryResume0(cancellableContinuation, obj2, function12 != null ? OnUndeliveredElementKt.bindCancellationFun(function12, obj2, cancellableContinuation.getContext()) : null);
return tryResume0;
}
throw new IllegalStateException(("Unexpected receiver type: " + obj).toString());
}
public static /* synthetic */ Object receive$suspendImpl(BufferedChannel bufferedChannel, Continuation continuation) {
ChannelSegment channelSegment;
Symbol symbol;
Symbol symbol2;
Symbol symbol3;
ChannelSegment channelSegment2 = (ChannelSegment) receiveSegment$FU.get(bufferedChannel);
while (!bufferedChannel.isClosedForReceive()) {
long andIncrement = receivers$FU.getAndIncrement(bufferedChannel);
int i = BufferedChannelKt.SEGMENT_SIZE;
long j = andIncrement / i;
int i2 = (int) (andIncrement % i);
if (channelSegment2.id != j) {
ChannelSegment findSegmentReceive = bufferedChannel.findSegmentReceive(j, channelSegment2);
if (findSegmentReceive == null) {
continue;
} else {
channelSegment = findSegmentReceive;
}
} else {
channelSegment = channelSegment2;
}
Object updateCellReceive = bufferedChannel.updateCellReceive(channelSegment, i2, andIncrement, null);
symbol = BufferedChannelKt.SUSPEND;
if (updateCellReceive == symbol) {
throw new IllegalStateException("unexpected".toString());
}
symbol2 = BufferedChannelKt.FAILED;
if (updateCellReceive != symbol2) {
symbol3 = BufferedChannelKt.SUSPEND_NO_WAITER;
if (updateCellReceive == symbol3) {
return bufferedChannel.receiveOnNoWaiterSuspend(channelSegment, i2, andIncrement, continuation);
}
channelSegment.cleanPrev();
return updateCellReceive;
}
if (andIncrement < bufferedChannel.getSendersCounter$kotlinx_coroutines_core()) {
channelSegment.cleanPrev();
}
channelSegment2 = channelSegment;
}
throw StackTraceRecoveryKt.recoverStackTrace(bufferedChannel.getReceiveException());
}
public final void prepareReceiverForSuspension(Waiter waiter, ChannelSegment channelSegment, int i) {
onReceiveEnqueued();
waiter.invokeOnCancellation(channelSegment, i);
}
public final void onClosedReceiveOnNoWaiterSuspend(CancellableContinuation cancellableContinuation) {
Result.Companion companion = Result.Companion;
cancellableContinuation.resumeWith(Result.m4060constructorimpl(ResultKt.createFailure(getReceiveException())));
}
/* JADX WARN: Removed duplicated region for block: B:15:0x003a */
/* JADX WARN: Removed duplicated region for block: B:9:0x0025 */
/* renamed from: receiveCatching-JP2dKIU$suspendImpl, reason: not valid java name */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static /* synthetic */ java.lang.Object m4122receiveCatchingJP2dKIU$suspendImpl(kotlinx.coroutines.channels.BufferedChannel r14, kotlin.coroutines.Continuation r15) {
/*
boolean r0 = r15 instanceof kotlinx.coroutines.channels.BufferedChannel$receiveCatching$1
if (r0 == 0) goto L14
r0 = r15
kotlinx.coroutines.channels.BufferedChannel$receiveCatching$1 r0 = (kotlinx.coroutines.channels.BufferedChannel$receiveCatching$1) r0
int r1 = r0.label
r2 = -2147483648(0xffffffff80000000, float:-0.0)
r3 = r1 & r2
if (r3 == 0) goto L14
int r1 = r1 - r2
r0.label = r1
L12:
r6 = r0
goto L1a
L14:
kotlinx.coroutines.channels.BufferedChannel$receiveCatching$1 r0 = new kotlinx.coroutines.channels.BufferedChannel$receiveCatching$1
r0.<init>(r14, r15)
goto L12
L1a:
java.lang.Object r15 = r6.result
java.lang.Object r0 = kotlin.coroutines.intrinsics.IntrinsicsKt.getCOROUTINE_SUSPENDED()
int r1 = r6.label
r2 = 1
if (r1 == 0) goto L3a
if (r1 != r2) goto L32
kotlin.ResultKt.throwOnFailure(r15)
kotlinx.coroutines.channels.ChannelResult r15 = (kotlinx.coroutines.channels.ChannelResult) r15
java.lang.Object r14 = r15.m4136unboximpl()
goto Lb7
L32:
java.lang.IllegalStateException r14 = new java.lang.IllegalStateException
java.lang.String r15 = "call to 'resume' before 'invoke' with coroutine"
r14.<init>(r15)
throw r14
L3a:
kotlin.ResultKt.throwOnFailure(r15)
r15 = 0
java.util.concurrent.atomic.AtomicReferenceFieldUpdater r1 = access$getReceiveSegment$FU$p()
java.lang.Object r1 = r1.get(r14)
kotlinx.coroutines.channels.ChannelSegment r1 = (kotlinx.coroutines.channels.ChannelSegment) r1
L48:
boolean r3 = r14.isClosedForReceive()
if (r3 == 0) goto L5a
kotlinx.coroutines.channels.ChannelResult$Companion r15 = kotlinx.coroutines.channels.ChannelResult.Companion
java.lang.Throwable r14 = r14.getCloseCause()
java.lang.Object r14 = r15.m4137closedJP2dKIU(r14)
goto Lb7
L5a:
java.util.concurrent.atomic.AtomicLongFieldUpdater r3 = access$getReceivers$FU$p()
long r4 = r3.getAndIncrement(r14)
int r3 = kotlinx.coroutines.channels.BufferedChannelKt.SEGMENT_SIZE
long r7 = (long) r3
long r7 = r4 / r7
long r9 = (long) r3
long r9 = r4 % r9
int r3 = (int) r9
long r9 = r1.id
int r9 = (r9 > r7 ? 1 : (r9 == r7 ? 0 : -1))
if (r9 == 0) goto L7a
kotlinx.coroutines.channels.ChannelSegment r7 = access$findSegmentReceive(r14, r7, r1)
if (r7 != 0) goto L78
goto L48
L78:
r13 = r7
goto L7b
L7a:
r13 = r1
L7b:
r7 = r14
r8 = r13
r9 = r3
r10 = r4
r12 = r15
java.lang.Object r1 = access$updateCellReceive(r7, r8, r9, r10, r12)
kotlinx.coroutines.internal.Symbol r7 = kotlinx.coroutines.channels.BufferedChannelKt.access$getSUSPEND$p()
if (r1 == r7) goto Lb8
kotlinx.coroutines.internal.Symbol r7 = kotlinx.coroutines.channels.BufferedChannelKt.access$getFAILED$p()
if (r1 != r7) goto L9d
long r7 = r14.getSendersCounter$kotlinx_coroutines_core()
int r1 = (r4 > r7 ? 1 : (r4 == r7 ? 0 : -1))
if (r1 >= 0) goto L9b
r13.cleanPrev()
L9b:
r1 = r13
goto L48
L9d:
kotlinx.coroutines.internal.Symbol r15 = kotlinx.coroutines.channels.BufferedChannelKt.access$getSUSPEND_NO_WAITER$p()
if (r1 != r15) goto Lae
r6.label = r2
r1 = r14
r2 = r13
java.lang.Object r14 = r1.m4124receiveCatchingOnNoWaiterSuspendGKJJFZk(r2, r3, r4, r6)
if (r14 != r0) goto Lb7
return r0
Lae:
r13.cleanPrev()
kotlinx.coroutines.channels.ChannelResult$Companion r14 = kotlinx.coroutines.channels.ChannelResult.Companion
java.lang.Object r14 = r14.m4139successJP2dKIU(r1)
Lb7:
return r14
Lb8:
java.lang.IllegalStateException r14 = new java.lang.IllegalStateException
java.lang.String r15 = "unexpected"
java.lang.String r15 = r15.toString()
r14.<init>(r15)
throw r14
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.channels.BufferedChannel.m4122receiveCatchingJP2dKIU$suspendImpl(kotlinx.coroutines.channels.BufferedChannel, kotlin.coroutines.Continuation):java.lang.Object");
}
/* JADX WARN: Removed duplicated region for block: B:15:0x003a */
/* JADX WARN: Removed duplicated region for block: B:8:0x0023 */
/* renamed from: receiveCatchingOnNoWaiterSuspend-GKJJFZk, reason: not valid java name */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final java.lang.Object m4124receiveCatchingOnNoWaiterSuspendGKJJFZk(kotlinx.coroutines.channels.ChannelSegment r11, int r12, long r13, kotlin.coroutines.Continuation r15) {
/*
Method dump skipped, instructions count: 319
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.channels.BufferedChannel.m4124receiveCatchingOnNoWaiterSuspendGKJJFZk(kotlinx.coroutines.channels.ChannelSegment, int, long, kotlin.coroutines.Continuation):java.lang.Object");
}
public final void onClosedReceiveCatchingOnNoWaiterSuspend(CancellableContinuation cancellableContinuation) {
Result.Companion companion = Result.Companion;
cancellableContinuation.resumeWith(Result.m4060constructorimpl(ChannelResult.m4127boximpl(ChannelResult.Companion.m4137closedJP2dKIU(getCloseCause()))));
}
@Override // kotlinx.coroutines.channels.ReceiveChannel
/* renamed from: tryReceive-PtdJZtk, reason: not valid java name */
public Object mo4125tryReceivePtdJZtk() {
Object obj;
ChannelSegment channelSegment;
Symbol symbol;
Symbol symbol2;
Symbol symbol3;
long j = receivers$FU.get(this);
long j2 = sendersAndCloseStatus$FU.get(this);
if (isClosedForReceive0(j2)) {
return ChannelResult.Companion.m4137closedJP2dKIU(getCloseCause());
}
if (j >= (j2 & 1152921504606846975L)) {
return ChannelResult.Companion.m4138failurePtdJZtk();
}
obj = BufferedChannelKt.INTERRUPTED_RCV;
ChannelSegment channelSegment2 = (ChannelSegment) receiveSegment$FU.get(this);
while (!isClosedForReceive()) {
long andIncrement = receivers$FU.getAndIncrement(this);
int i = BufferedChannelKt.SEGMENT_SIZE;
long j3 = andIncrement / i;
int i2 = (int) (andIncrement % i);
if (channelSegment2.id != j3) {
ChannelSegment findSegmentReceive = findSegmentReceive(j3, channelSegment2);
if (findSegmentReceive == null) {
continue;
} else {
channelSegment = findSegmentReceive;
}
} else {
channelSegment = channelSegment2;
}
Object updateCellReceive = updateCellReceive(channelSegment, i2, andIncrement, obj);
symbol = BufferedChannelKt.SUSPEND;
if (updateCellReceive == symbol) {
Waiter waiter = obj instanceof Waiter ? (Waiter) obj : null;
if (waiter != null) {
prepareReceiverForSuspension(waiter, channelSegment, i2);
}
waitExpandBufferCompletion$kotlinx_coroutines_core(andIncrement);
channelSegment.onSlotCleaned();
return ChannelResult.Companion.m4138failurePtdJZtk();
}
symbol2 = BufferedChannelKt.FAILED;
if (updateCellReceive != symbol2) {
symbol3 = BufferedChannelKt.SUSPEND_NO_WAITER;
if (updateCellReceive == symbol3) {
throw new IllegalStateException("unexpected".toString());
}
channelSegment.cleanPrev();
return ChannelResult.Companion.m4139successJP2dKIU(updateCellReceive);
}
if (andIncrement < getSendersCounter$kotlinx_coroutines_core()) {
channelSegment.cleanPrev();
}
channelSegment2 = channelSegment;
}
return ChannelResult.Companion.m4137closedJP2dKIU(getCloseCause());
}
public final void dropFirstElementUntilTheSpecifiedCellIsInTheBuffer(long j) {
Symbol symbol;
UndeliveredElementException callUndeliveredElementCatchingException$default;
ChannelSegment channelSegment = (ChannelSegment) receiveSegment$FU.get(this);
while (true) {
AtomicLongFieldUpdater atomicLongFieldUpdater = receivers$FU;
long j2 = atomicLongFieldUpdater.get(this);
if (j < Math.max(this.capacity + j2, getBufferEndCounter())) {
return;
}
if (atomicLongFieldUpdater.compareAndSet(this, j2, j2 + 1)) {
int i = BufferedChannelKt.SEGMENT_SIZE;
long j3 = j2 / i;
int i2 = (int) (j2 % i);
if (channelSegment.id != j3) {
ChannelSegment findSegmentReceive = findSegmentReceive(j3, channelSegment);
if (findSegmentReceive == null) {
continue;
} else {
channelSegment = findSegmentReceive;
}
}
Object updateCellReceive = updateCellReceive(channelSegment, i2, j2, null);
symbol = BufferedChannelKt.FAILED;
if (updateCellReceive != symbol) {
channelSegment.cleanPrev();
Function1 function1 = this.onUndeliveredElement;
if (function1 != null && (callUndeliveredElementCatchingException$default = OnUndeliveredElementKt.callUndeliveredElementCatchingException$default(function1, updateCellReceive, null, 2, null)) != null) {
throw callUndeliveredElementCatchingException$default;
}
} else if (j2 < getSendersCounter$kotlinx_coroutines_core()) {
channelSegment.cleanPrev();
}
}
}
}
public final Object updateCellReceive(ChannelSegment channelSegment, int i, long j, Object obj) {
Symbol symbol;
Symbol symbol2;
Symbol symbol3;
Object state$kotlinx_coroutines_core = channelSegment.getState$kotlinx_coroutines_core(i);
if (state$kotlinx_coroutines_core == null) {
if (j >= (sendersAndCloseStatus$FU.get(this) & 1152921504606846975L)) {
if (obj == null) {
symbol3 = BufferedChannelKt.SUSPEND_NO_WAITER;
return symbol3;
}
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, obj)) {
expandBuffer();
symbol2 = BufferedChannelKt.SUSPEND;
return symbol2;
}
}
} else if (state$kotlinx_coroutines_core == BufferedChannelKt.BUFFERED) {
symbol = BufferedChannelKt.DONE_RCV;
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, symbol)) {
expandBuffer();
return channelSegment.retrieveElement$kotlinx_coroutines_core(i);
}
}
return updateCellReceiveSlow(channelSegment, i, j, obj);
}
public final Object updateCellReceiveSlow(ChannelSegment channelSegment, int i, long j, Object obj) {
Symbol symbol;
Symbol symbol2;
Symbol symbol3;
Symbol symbol4;
Symbol symbol5;
Symbol symbol6;
Symbol symbol7;
Symbol symbol8;
Symbol symbol9;
Symbol symbol10;
Symbol symbol11;
Symbol symbol12;
Symbol symbol13;
Symbol symbol14;
Symbol symbol15;
Symbol symbol16;
while (true) {
Object state$kotlinx_coroutines_core = channelSegment.getState$kotlinx_coroutines_core(i);
if (state$kotlinx_coroutines_core != null) {
symbol5 = BufferedChannelKt.IN_BUFFER;
if (state$kotlinx_coroutines_core != symbol5) {
if (state$kotlinx_coroutines_core == BufferedChannelKt.BUFFERED) {
symbol6 = BufferedChannelKt.DONE_RCV;
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, symbol6)) {
expandBuffer();
return channelSegment.retrieveElement$kotlinx_coroutines_core(i);
}
} else {
symbol7 = BufferedChannelKt.INTERRUPTED_SEND;
if (state$kotlinx_coroutines_core == symbol7) {
symbol8 = BufferedChannelKt.FAILED;
return symbol8;
}
symbol9 = BufferedChannelKt.POISONED;
if (state$kotlinx_coroutines_core == symbol9) {
symbol10 = BufferedChannelKt.FAILED;
return symbol10;
}
if (state$kotlinx_coroutines_core == BufferedChannelKt.getCHANNEL_CLOSED()) {
expandBuffer();
symbol11 = BufferedChannelKt.FAILED;
return symbol11;
}
symbol12 = BufferedChannelKt.RESUMING_BY_EB;
if (state$kotlinx_coroutines_core != symbol12) {
symbol13 = BufferedChannelKt.RESUMING_BY_RCV;
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, symbol13)) {
boolean z = state$kotlinx_coroutines_core instanceof WaiterEB;
if (z) {
state$kotlinx_coroutines_core = ((WaiterEB) state$kotlinx_coroutines_core).waiter;
}
if (tryResumeSender(state$kotlinx_coroutines_core, channelSegment, i)) {
symbol16 = BufferedChannelKt.DONE_RCV;
channelSegment.setState$kotlinx_coroutines_core(i, symbol16);
expandBuffer();
return channelSegment.retrieveElement$kotlinx_coroutines_core(i);
}
symbol14 = BufferedChannelKt.INTERRUPTED_SEND;
channelSegment.setState$kotlinx_coroutines_core(i, symbol14);
channelSegment.onCancelledRequest(i, false);
if (z) {
expandBuffer();
}
symbol15 = BufferedChannelKt.FAILED;
return symbol15;
}
} else {
continue;
}
}
}
}
if (j < (sendersAndCloseStatus$FU.get(this) & 1152921504606846975L)) {
symbol = BufferedChannelKt.POISONED;
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, symbol)) {
expandBuffer();
symbol2 = BufferedChannelKt.FAILED;
return symbol2;
}
} else {
if (obj == null) {
symbol3 = BufferedChannelKt.SUSPEND_NO_WAITER;
return symbol3;
}
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, obj)) {
expandBuffer();
symbol4 = BufferedChannelKt.SUSPEND;
return symbol4;
}
}
}
}
public final boolean tryResumeSender(Object obj, ChannelSegment channelSegment, int i) {
if (obj instanceof CancellableContinuation) {
Intrinsics.checkNotNull(obj, "null cannot be cast to non-null type kotlinx.coroutines.CancellableContinuation<kotlin.Unit>");
return BufferedChannelKt.tryResume0$default((CancellableContinuation) obj, Unit.INSTANCE, null, 2, null);
}
throw new IllegalStateException(("Unexpected waiter: " + obj).toString());
}
public final void expandBuffer() {
if (isRendezvousOrUnlimited()) {
return;
}
ChannelSegment channelSegment = (ChannelSegment) bufferEndSegment$FU.get(this);
while (true) {
long andIncrement = bufferEnd$FU.getAndIncrement(this);
int i = BufferedChannelKt.SEGMENT_SIZE;
long j = andIncrement / i;
if (getSendersCounter$kotlinx_coroutines_core() <= andIncrement) {
if (channelSegment.id < j && channelSegment.getNext() != null) {
moveSegmentBufferEndToSpecifiedOrLast(j, channelSegment);
}
incCompletedExpandBufferAttempts$default(this, 0L, 1, null);
return;
}
if (channelSegment.id != j) {
ChannelSegment findSegmentBufferEnd = findSegmentBufferEnd(j, channelSegment, andIncrement);
if (findSegmentBufferEnd == null) {
continue;
} else {
channelSegment = findSegmentBufferEnd;
}
}
if (updateCellExpandBuffer(channelSegment, (int) (andIncrement % i), andIncrement)) {
incCompletedExpandBufferAttempts$default(this, 0L, 1, null);
return;
}
incCompletedExpandBufferAttempts$default(this, 0L, 1, null);
}
}
public final boolean updateCellExpandBuffer(ChannelSegment channelSegment, int i, long j) {
Symbol symbol;
Symbol symbol2;
Object state$kotlinx_coroutines_core = channelSegment.getState$kotlinx_coroutines_core(i);
if ((state$kotlinx_coroutines_core instanceof Waiter) && j >= receivers$FU.get(this)) {
symbol = BufferedChannelKt.RESUMING_BY_EB;
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, symbol)) {
if (tryResumeSender(state$kotlinx_coroutines_core, channelSegment, i)) {
channelSegment.setState$kotlinx_coroutines_core(i, BufferedChannelKt.BUFFERED);
return true;
}
symbol2 = BufferedChannelKt.INTERRUPTED_SEND;
channelSegment.setState$kotlinx_coroutines_core(i, symbol2);
channelSegment.onCancelledRequest(i, false);
return false;
}
}
return updateCellExpandBufferSlow(channelSegment, i, j);
}
public final boolean updateCellExpandBufferSlow(ChannelSegment channelSegment, int i, long j) {
Symbol symbol;
Symbol symbol2;
Symbol symbol3;
Symbol symbol4;
Symbol symbol5;
Symbol symbol6;
Symbol symbol7;
Symbol symbol8;
while (true) {
Object state$kotlinx_coroutines_core = channelSegment.getState$kotlinx_coroutines_core(i);
if (!(state$kotlinx_coroutines_core instanceof Waiter)) {
symbol3 = BufferedChannelKt.INTERRUPTED_SEND;
if (state$kotlinx_coroutines_core != symbol3) {
if (state$kotlinx_coroutines_core == null) {
symbol4 = BufferedChannelKt.IN_BUFFER;
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, symbol4)) {
return true;
}
} else if (state$kotlinx_coroutines_core != BufferedChannelKt.BUFFERED) {
symbol5 = BufferedChannelKt.POISONED;
if (state$kotlinx_coroutines_core == symbol5) {
break;
}
symbol6 = BufferedChannelKt.DONE_RCV;
if (state$kotlinx_coroutines_core == symbol6) {
break;
}
symbol7 = BufferedChannelKt.INTERRUPTED_RCV;
if (state$kotlinx_coroutines_core == symbol7 || state$kotlinx_coroutines_core == BufferedChannelKt.getCHANNEL_CLOSED()) {
return true;
}
symbol8 = BufferedChannelKt.RESUMING_BY_RCV;
if (state$kotlinx_coroutines_core != symbol8) {
throw new IllegalStateException(("Unexpected cell state: " + state$kotlinx_coroutines_core).toString());
}
} else {
return true;
}
} else {
return false;
}
} else if (j < receivers$FU.get(this)) {
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, new WaiterEB((Waiter) state$kotlinx_coroutines_core))) {
return true;
}
} else {
symbol = BufferedChannelKt.RESUMING_BY_EB;
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, symbol)) {
if (tryResumeSender(state$kotlinx_coroutines_core, channelSegment, i)) {
channelSegment.setState$kotlinx_coroutines_core(i, BufferedChannelKt.BUFFERED);
return true;
}
symbol2 = BufferedChannelKt.INTERRUPTED_SEND;
channelSegment.setState$kotlinx_coroutines_core(i, symbol2);
channelSegment.onCancelledRequest(i, false);
return false;
}
}
}
}
public static /* synthetic */ void incCompletedExpandBufferAttempts$default(BufferedChannel bufferedChannel, long j, int i, Object obj) {
if (obj != null) {
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: incCompletedExpandBufferAttempts");
}
if ((i & 1) != 0) {
j = 1;
}
bufferedChannel.incCompletedExpandBufferAttempts(j);
}
public final void incCompletedExpandBufferAttempts(long j) {
if ((completedExpandBuffersAndPauseFlag$FU.addAndGet(this, j) & 4611686018427387904L) != 0) {
while ((completedExpandBuffersAndPauseFlag$FU.get(this) & 4611686018427387904L) != 0) {
}
}
}
public final void waitExpandBufferCompletion$kotlinx_coroutines_core(long j) {
int i;
long j2;
long constructEBCompletedAndPauseFlag;
AtomicLongFieldUpdater atomicLongFieldUpdater;
long constructEBCompletedAndPauseFlag2;
long j3;
long constructEBCompletedAndPauseFlag3;
if (isRendezvousOrUnlimited()) {
return;
}
while (getBufferEndCounter() <= j) {
}
i = BufferedChannelKt.EXPAND_BUFFER_COMPLETION_WAIT_ITERATIONS;
for (int i2 = 0; i2 < i; i2++) {
long bufferEndCounter = getBufferEndCounter();
if (bufferEndCounter == (4611686018427387903L & completedExpandBuffersAndPauseFlag$FU.get(this)) && bufferEndCounter == getBufferEndCounter()) {
return;
}
}
AtomicLongFieldUpdater atomicLongFieldUpdater2 = completedExpandBuffersAndPauseFlag$FU;
do {
j2 = atomicLongFieldUpdater2.get(this);
constructEBCompletedAndPauseFlag = BufferedChannelKt.constructEBCompletedAndPauseFlag(j2 & 4611686018427387903L, true);
} while (!atomicLongFieldUpdater2.compareAndSet(this, j2, constructEBCompletedAndPauseFlag));
while (true) {
long bufferEndCounter2 = getBufferEndCounter();
atomicLongFieldUpdater = completedExpandBuffersAndPauseFlag$FU;
long j4 = atomicLongFieldUpdater.get(this);
long j5 = j4 & 4611686018427387903L;
boolean z = (4611686018427387904L & j4) != 0;
if (bufferEndCounter2 == j5 && bufferEndCounter2 == getBufferEndCounter()) {
break;
} else if (!z) {
constructEBCompletedAndPauseFlag2 = BufferedChannelKt.constructEBCompletedAndPauseFlag(j5, true);
atomicLongFieldUpdater.compareAndSet(this, j4, constructEBCompletedAndPauseFlag2);
}
}
do {
j3 = atomicLongFieldUpdater.get(this);
constructEBCompletedAndPauseFlag3 = BufferedChannelKt.constructEBCompletedAndPauseFlag(j3 & 4611686018427387903L, false);
} while (!atomicLongFieldUpdater.compareAndSet(this, j3, constructEBCompletedAndPauseFlag3));
}
@Override // kotlinx.coroutines.channels.ReceiveChannel
public ChannelIterator iterator() {
return new BufferedChannelIterator();
}
public final Throwable getCloseCause() {
return (Throwable) _closeCause$FU.get(this);
}
public final Throwable getSendException() {
Throwable closeCause = getCloseCause();
return closeCause == null ? new ClosedSendChannelException("Channel was closed") : closeCause;
}
public final Throwable getReceiveException() {
Throwable closeCause = getCloseCause();
return closeCause == null ? new ClosedReceiveChannelException("Channel was closed") : closeCause;
}
@Override // kotlinx.coroutines.channels.SendChannel
public boolean close(Throwable th) {
return closeOrCancelImpl(th, false);
}
@Override // kotlinx.coroutines.channels.ReceiveChannel
public final void cancel(CancellationException cancellationException) {
cancelImpl$kotlinx_coroutines_core(cancellationException);
}
public boolean cancelImpl$kotlinx_coroutines_core(Throwable th) {
if (th == null) {
th = new CancellationException("Channel was cancelled");
}
return closeOrCancelImpl(th, true);
}
public boolean closeOrCancelImpl(Throwable th, boolean z) {
Symbol symbol;
if (z) {
markCancellationStarted();
}
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = _closeCause$FU;
symbol = BufferedChannelKt.NO_CLOSE_CAUSE;
boolean m = AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, symbol, th);
if (z) {
markCancelled();
} else {
markClosed();
}
completeCloseOrCancel();
onClosedIdempotent();
if (m) {
invokeCloseHandler();
}
return m;
}
public final void invokeCloseHandler() {
Object obj;
Symbol symbol;
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = closeHandler$FU;
do {
obj = atomicReferenceFieldUpdater.get(this);
if (obj == null) {
symbol = BufferedChannelKt.CLOSE_HANDLER_CLOSED;
} else {
symbol = BufferedChannelKt.CLOSE_HANDLER_INVOKED;
}
} while (!AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, obj, symbol));
if (obj == null) {
return;
}
((Function1) obj).invoke(getCloseCause());
}
@Override // kotlinx.coroutines.channels.SendChannel
public void invokeOnClose(Function1 function1) {
Symbol symbol;
Symbol symbol2;
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater;
Symbol symbol3;
Symbol symbol4;
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = closeHandler$FU;
if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater2, this, null, function1)) {
return;
}
do {
Object obj = atomicReferenceFieldUpdater2.get(this);
symbol = BufferedChannelKt.CLOSE_HANDLER_CLOSED;
if (obj == symbol) {
atomicReferenceFieldUpdater = closeHandler$FU;
symbol3 = BufferedChannelKt.CLOSE_HANDLER_CLOSED;
symbol4 = BufferedChannelKt.CLOSE_HANDLER_INVOKED;
} else {
symbol2 = BufferedChannelKt.CLOSE_HANDLER_INVOKED;
if (obj == symbol2) {
throw new IllegalStateException("Another handler was already registered and successfully invoked".toString());
}
throw new IllegalStateException(("Another handler is already registered: " + obj).toString());
}
} while (!AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, symbol3, symbol4));
function1.invoke(getCloseCause());
}
public final void markClosed() {
long j;
long constructSendersAndCloseStatus;
AtomicLongFieldUpdater atomicLongFieldUpdater = sendersAndCloseStatus$FU;
do {
j = atomicLongFieldUpdater.get(this);
int i = (int) (j >> 60);
if (i == 0) {
constructSendersAndCloseStatus = BufferedChannelKt.constructSendersAndCloseStatus(j & 1152921504606846975L, 2);
} else if (i != 1) {
return;
} else {
constructSendersAndCloseStatus = BufferedChannelKt.constructSendersAndCloseStatus(j & 1152921504606846975L, 3);
}
} while (!atomicLongFieldUpdater.compareAndSet(this, j, constructSendersAndCloseStatus));
}
public final void markCancelled() {
long j;
long constructSendersAndCloseStatus;
AtomicLongFieldUpdater atomicLongFieldUpdater = sendersAndCloseStatus$FU;
do {
j = atomicLongFieldUpdater.get(this);
constructSendersAndCloseStatus = BufferedChannelKt.constructSendersAndCloseStatus(1152921504606846975L & j, 3);
} while (!atomicLongFieldUpdater.compareAndSet(this, j, constructSendersAndCloseStatus));
}
public final void markCancellationStarted() {
long j;
long constructSendersAndCloseStatus;
AtomicLongFieldUpdater atomicLongFieldUpdater = sendersAndCloseStatus$FU;
do {
j = atomicLongFieldUpdater.get(this);
if (((int) (j >> 60)) != 0) {
return;
} else {
constructSendersAndCloseStatus = BufferedChannelKt.constructSendersAndCloseStatus(1152921504606846975L & j, 1);
}
} while (!atomicLongFieldUpdater.compareAndSet(this, j, constructSendersAndCloseStatus));
}
public final void completeCloseOrCancel() {
isClosedForSend();
}
public final ChannelSegment completeClose(long j) {
ChannelSegment closeLinkedList = closeLinkedList();
if (isConflatedDropOldest()) {
long markAllEmptyCellsAsClosed = markAllEmptyCellsAsClosed(closeLinkedList);
if (markAllEmptyCellsAsClosed != -1) {
dropFirstElementUntilTheSpecifiedCellIsInTheBuffer(markAllEmptyCellsAsClosed);
}
}
cancelSuspendedReceiveRequests(closeLinkedList, j);
return closeLinkedList;
}
public final void completeCancel(long j) {
removeUnprocessedElements(completeClose(j));
}
public final ChannelSegment closeLinkedList() {
Object obj = bufferEndSegment$FU.get(this);
ChannelSegment channelSegment = (ChannelSegment) sendSegment$FU.get(this);
if (channelSegment.id > ((ChannelSegment) obj).id) {
obj = channelSegment;
}
ChannelSegment channelSegment2 = (ChannelSegment) receiveSegment$FU.get(this);
if (channelSegment2.id > ((ChannelSegment) obj).id) {
obj = channelSegment2;
}
return (ChannelSegment) ConcurrentLinkedListKt.close((ConcurrentLinkedListNode) obj);
}
/* JADX WARN: Code restructure failed: missing block: B:27:0x003c, code lost:
r8 = (kotlinx.coroutines.channels.ChannelSegment) r8.getPrev();
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final long markAllEmptyCellsAsClosed(kotlinx.coroutines.channels.ChannelSegment r8) {
/*
r7 = this;
L0:
int r0 = kotlinx.coroutines.channels.BufferedChannelKt.SEGMENT_SIZE
int r0 = r0 + (-1)
L4:
r1 = -1
r3 = -1
if (r3 >= r0) goto L3c
long r3 = r8.id
int r5 = kotlinx.coroutines.channels.BufferedChannelKt.SEGMENT_SIZE
long r5 = (long) r5
long r3 = r3 * r5
long r5 = (long) r0
long r3 = r3 + r5
long r5 = r7.getReceiversCounter$kotlinx_coroutines_core()
int r5 = (r3 > r5 ? 1 : (r3 == r5 ? 0 : -1))
if (r5 >= 0) goto L1a
return r1
L1a:
java.lang.Object r1 = r8.getState$kotlinx_coroutines_core(r0)
if (r1 == 0) goto L2c
kotlinx.coroutines.internal.Symbol r2 = kotlinx.coroutines.channels.BufferedChannelKt.access$getIN_BUFFER$p()
if (r1 != r2) goto L27
goto L2c
L27:
kotlinx.coroutines.internal.Symbol r2 = kotlinx.coroutines.channels.BufferedChannelKt.BUFFERED
if (r1 != r2) goto L39
return r3
L2c:
kotlinx.coroutines.internal.Symbol r2 = kotlinx.coroutines.channels.BufferedChannelKt.getCHANNEL_CLOSED()
boolean r1 = r8.casState$kotlinx_coroutines_core(r0, r1, r2)
if (r1 == 0) goto L1a
r8.onSlotCleaned()
L39:
int r0 = r0 + (-1)
goto L4
L3c:
kotlinx.coroutines.internal.ConcurrentLinkedListNode r8 = r8.getPrev()
kotlinx.coroutines.channels.ChannelSegment r8 = (kotlinx.coroutines.channels.ChannelSegment) r8
if (r8 != 0) goto L0
return r1
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.channels.BufferedChannel.markAllEmptyCellsAsClosed(kotlinx.coroutines.channels.ChannelSegment):long");
}
/* JADX WARN: Code restructure failed: missing block: B:83:0x00b3, code lost:
r12 = (kotlinx.coroutines.channels.ChannelSegment) r12.getPrev();
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final void removeUnprocessedElements(kotlinx.coroutines.channels.ChannelSegment r12) {
/*
r11 = this;
kotlin.jvm.functions.Function1 r0 = r11.onUndeliveredElement
r1 = 0
r2 = 1
java.lang.Object r3 = kotlinx.coroutines.internal.InlineList.m4146constructorimpl$default(r1, r2, r1)
L8:
int r4 = kotlinx.coroutines.channels.BufferedChannelKt.SEGMENT_SIZE
int r4 = r4 - r2
Lb:
r5 = -1
if (r5 >= r4) goto Lb3
long r6 = r12.id
int r8 = kotlinx.coroutines.channels.BufferedChannelKt.SEGMENT_SIZE
long r8 = (long) r8
long r6 = r6 * r8
long r8 = (long) r4
long r6 = r6 + r8
L16:
java.lang.Object r8 = r12.getState$kotlinx_coroutines_core(r4)
kotlinx.coroutines.internal.Symbol r9 = kotlinx.coroutines.channels.BufferedChannelKt.access$getDONE_RCV$p()
if (r8 == r9) goto Lbb
kotlinx.coroutines.internal.Symbol r9 = kotlinx.coroutines.channels.BufferedChannelKt.BUFFERED
if (r8 != r9) goto L48
long r9 = r11.getReceiversCounter$kotlinx_coroutines_core()
int r9 = (r6 > r9 ? 1 : (r6 == r9 ? 0 : -1))
if (r9 < 0) goto Lbb
kotlinx.coroutines.internal.Symbol r9 = kotlinx.coroutines.channels.BufferedChannelKt.getCHANNEL_CLOSED()
boolean r8 = r12.casState$kotlinx_coroutines_core(r4, r8, r9)
if (r8 == 0) goto L16
if (r0 == 0) goto L40
java.lang.Object r5 = r12.getElement$kotlinx_coroutines_core(r4)
kotlinx.coroutines.internal.UndeliveredElementException r1 = kotlinx.coroutines.internal.OnUndeliveredElementKt.callUndeliveredElementCatchingException(r0, r5, r1)
L40:
r12.cleanElement$kotlinx_coroutines_core(r4)
r12.onSlotCleaned()
goto Laf
L48:
kotlinx.coroutines.internal.Symbol r9 = kotlinx.coroutines.channels.BufferedChannelKt.access$getIN_BUFFER$p()
if (r8 == r9) goto La2
if (r8 != 0) goto L51
goto La2
L51:
boolean r9 = r8 instanceof kotlinx.coroutines.Waiter
if (r9 != 0) goto L6e
boolean r9 = r8 instanceof kotlinx.coroutines.channels.WaiterEB
if (r9 == 0) goto L5a
goto L6e
L5a:
kotlinx.coroutines.internal.Symbol r9 = kotlinx.coroutines.channels.BufferedChannelKt.access$getRESUMING_BY_EB$p()
if (r8 == r9) goto Lbb
kotlinx.coroutines.internal.Symbol r9 = kotlinx.coroutines.channels.BufferedChannelKt.access$getRESUMING_BY_RCV$p()
if (r8 != r9) goto L67
goto Lbb
L67:
kotlinx.coroutines.internal.Symbol r9 = kotlinx.coroutines.channels.BufferedChannelKt.access$getRESUMING_BY_EB$p()
if (r8 == r9) goto L16
goto Laf
L6e:
long r9 = r11.getReceiversCounter$kotlinx_coroutines_core()
int r9 = (r6 > r9 ? 1 : (r6 == r9 ? 0 : -1))
if (r9 < 0) goto Lbb
boolean r9 = r8 instanceof kotlinx.coroutines.channels.WaiterEB
if (r9 == 0) goto L80
r9 = r8
kotlinx.coroutines.channels.WaiterEB r9 = (kotlinx.coroutines.channels.WaiterEB) r9
kotlinx.coroutines.Waiter r9 = r9.waiter
goto L83
L80:
r9 = r8
kotlinx.coroutines.Waiter r9 = (kotlinx.coroutines.Waiter) r9
L83:
kotlinx.coroutines.internal.Symbol r10 = kotlinx.coroutines.channels.BufferedChannelKt.getCHANNEL_CLOSED()
boolean r8 = r12.casState$kotlinx_coroutines_core(r4, r8, r10)
if (r8 == 0) goto L16
if (r0 == 0) goto L97
java.lang.Object r5 = r12.getElement$kotlinx_coroutines_core(r4)
kotlinx.coroutines.internal.UndeliveredElementException r1 = kotlinx.coroutines.internal.OnUndeliveredElementKt.callUndeliveredElementCatchingException(r0, r5, r1)
L97:
java.lang.Object r3 = kotlinx.coroutines.internal.InlineList.m4147plusFjFbRPM(r3, r9)
r12.cleanElement$kotlinx_coroutines_core(r4)
r12.onSlotCleaned()
goto Laf
La2:
kotlinx.coroutines.internal.Symbol r9 = kotlinx.coroutines.channels.BufferedChannelKt.getCHANNEL_CLOSED()
boolean r8 = r12.casState$kotlinx_coroutines_core(r4, r8, r9)
if (r8 == 0) goto L16
r12.onSlotCleaned()
Laf:
int r4 = r4 + (-1)
goto Lb
Lb3:
kotlinx.coroutines.internal.ConcurrentLinkedListNode r12 = r12.getPrev()
kotlinx.coroutines.channels.ChannelSegment r12 = (kotlinx.coroutines.channels.ChannelSegment) r12
if (r12 != 0) goto L8
Lbb:
if (r3 == 0) goto Le1
boolean r12 = r3 instanceof java.util.ArrayList
if (r12 != 0) goto Lc7
kotlinx.coroutines.Waiter r3 = (kotlinx.coroutines.Waiter) r3
r11.resumeSenderOnCancelledChannel(r3)
goto Le1
Lc7:
java.lang.String r12 = "null cannot be cast to non-null type java.util.ArrayList<E of kotlinx.coroutines.internal.InlineList>{ kotlin.collections.TypeAliasesKt.ArrayList<E of kotlinx.coroutines.internal.InlineList> }"
kotlin.jvm.internal.Intrinsics.checkNotNull(r3, r12)
java.util.ArrayList r3 = (java.util.ArrayList) r3
int r12 = r3.size()
int r12 = r12 - r2
Ld3:
if (r5 >= r12) goto Le1
java.lang.Object r0 = r3.get(r12)
kotlinx.coroutines.Waiter r0 = (kotlinx.coroutines.Waiter) r0
r11.resumeSenderOnCancelledChannel(r0)
int r12 = r12 + (-1)
goto Ld3
Le1:
if (r1 != 0) goto Le4
return
Le4:
throw r1
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.channels.BufferedChannel.removeUnprocessedElements(kotlinx.coroutines.channels.ChannelSegment):void");
}
public final void cancelSuspendedReceiveRequests(ChannelSegment channelSegment, long j) {
Symbol symbol;
Object m4146constructorimpl$default = InlineList.m4146constructorimpl$default(null, 1, null);
loop0: while (channelSegment != null) {
for (int i = BufferedChannelKt.SEGMENT_SIZE - 1; -1 < i; i--) {
if ((channelSegment.id * BufferedChannelKt.SEGMENT_SIZE) + i < j) {
break loop0;
}
while (true) {
Object state$kotlinx_coroutines_core = channelSegment.getState$kotlinx_coroutines_core(i);
if (state$kotlinx_coroutines_core != null) {
symbol = BufferedChannelKt.IN_BUFFER;
if (state$kotlinx_coroutines_core != symbol) {
if (state$kotlinx_coroutines_core instanceof WaiterEB) {
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, BufferedChannelKt.getCHANNEL_CLOSED())) {
m4146constructorimpl$default = InlineList.m4147plusFjFbRPM(m4146constructorimpl$default, ((WaiterEB) state$kotlinx_coroutines_core).waiter);
channelSegment.onCancelledRequest(i, true);
break;
}
} else {
if (!(state$kotlinx_coroutines_core instanceof Waiter)) {
break;
}
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, BufferedChannelKt.getCHANNEL_CLOSED())) {
m4146constructorimpl$default = InlineList.m4147plusFjFbRPM(m4146constructorimpl$default, state$kotlinx_coroutines_core);
channelSegment.onCancelledRequest(i, true);
break;
}
}
}
}
if (channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, BufferedChannelKt.getCHANNEL_CLOSED())) {
channelSegment.onSlotCleaned();
break;
}
}
}
channelSegment = (ChannelSegment) channelSegment.getPrev();
}
if (m4146constructorimpl$default != null) {
if (m4146constructorimpl$default instanceof ArrayList) {
Intrinsics.checkNotNull(m4146constructorimpl$default, "null cannot be cast to non-null type java.util.ArrayList<E of kotlinx.coroutines.internal.InlineList>{ kotlin.collections.TypeAliasesKt.ArrayList<E of kotlinx.coroutines.internal.InlineList> }");
ArrayList arrayList = (ArrayList) m4146constructorimpl$default;
for (int size = arrayList.size() - 1; -1 < size; size--) {
resumeReceiverOnClosedChannel((Waiter) arrayList.get(size));
}
return;
}
resumeReceiverOnClosedChannel((Waiter) m4146constructorimpl$default);
}
}
public final void resumeReceiverOnClosedChannel(Waiter waiter) {
resumeWaiterOnClosedChannel(waiter, true);
}
public final void resumeSenderOnCancelledChannel(Waiter waiter) {
resumeWaiterOnClosedChannel(waiter, false);
}
public final void resumeWaiterOnClosedChannel(Waiter waiter, boolean z) {
if (waiter instanceof CancellableContinuation) {
Continuation continuation = (Continuation) waiter;
Result.Companion companion = Result.Companion;
continuation.resumeWith(Result.m4060constructorimpl(ResultKt.createFailure(z ? getReceiveException() : getSendException())));
} else if (waiter instanceof ReceiveCatching) {
CancellableContinuationImpl cancellableContinuationImpl = ((ReceiveCatching) waiter).cont;
Result.Companion companion2 = Result.Companion;
cancellableContinuationImpl.resumeWith(Result.m4060constructorimpl(ChannelResult.m4127boximpl(ChannelResult.Companion.m4137closedJP2dKIU(getCloseCause()))));
} else {
if (waiter instanceof BufferedChannelIterator) {
((BufferedChannelIterator) waiter).tryResumeHasNextOnClosedChannel();
return;
}
throw new IllegalStateException(("Unexpected waiter: " + waiter).toString());
}
}
@Override // kotlinx.coroutines.channels.SendChannel
public boolean isClosedForSend() {
return isClosedForSend0(sendersAndCloseStatus$FU.get(this));
}
public final boolean isClosedForSend0(long j) {
return isClosed(j, false);
}
public boolean isClosedForReceive() {
return isClosedForReceive0(sendersAndCloseStatus$FU.get(this));
}
public final boolean isClosedForReceive0(long j) {
return isClosed(j, true);
}
public final boolean isClosed(long j, boolean z) {
int i = (int) (j >> 60);
if (i == 0 || i == 1) {
return false;
}
if (i == 2) {
completeClose(j & 1152921504606846975L);
if (z && hasElements$kotlinx_coroutines_core()) {
return false;
}
} else if (i == 3) {
completeCancel(j & 1152921504606846975L);
} else {
throw new IllegalStateException(("unexpected close status: " + i).toString());
}
return true;
}
public final boolean hasElements$kotlinx_coroutines_core() {
while (true) {
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = receiveSegment$FU;
ChannelSegment channelSegment = (ChannelSegment) atomicReferenceFieldUpdater.get(this);
long receiversCounter$kotlinx_coroutines_core = getReceiversCounter$kotlinx_coroutines_core();
if (getSendersCounter$kotlinx_coroutines_core() <= receiversCounter$kotlinx_coroutines_core) {
return false;
}
int i = BufferedChannelKt.SEGMENT_SIZE;
long j = receiversCounter$kotlinx_coroutines_core / i;
if (channelSegment.id == j || (channelSegment = findSegmentReceive(j, channelSegment)) != null) {
channelSegment.cleanPrev();
if (isCellNonEmpty(channelSegment, (int) (receiversCounter$kotlinx_coroutines_core % i), receiversCounter$kotlinx_coroutines_core)) {
return true;
}
receivers$FU.compareAndSet(this, receiversCounter$kotlinx_coroutines_core, receiversCounter$kotlinx_coroutines_core + 1);
} else if (((ChannelSegment) atomicReferenceFieldUpdater.get(this)).id < j) {
return false;
}
}
}
public final boolean isCellNonEmpty(ChannelSegment channelSegment, int i, long j) {
Object state$kotlinx_coroutines_core;
Symbol symbol;
Symbol symbol2;
Symbol symbol3;
Symbol symbol4;
Symbol symbol5;
Symbol symbol6;
Symbol symbol7;
do {
state$kotlinx_coroutines_core = channelSegment.getState$kotlinx_coroutines_core(i);
if (state$kotlinx_coroutines_core != null) {
symbol2 = BufferedChannelKt.IN_BUFFER;
if (state$kotlinx_coroutines_core != symbol2) {
if (state$kotlinx_coroutines_core == BufferedChannelKt.BUFFERED) {
return true;
}
symbol3 = BufferedChannelKt.INTERRUPTED_SEND;
if (state$kotlinx_coroutines_core == symbol3 || state$kotlinx_coroutines_core == BufferedChannelKt.getCHANNEL_CLOSED()) {
return false;
}
symbol4 = BufferedChannelKt.DONE_RCV;
if (state$kotlinx_coroutines_core == symbol4) {
return false;
}
symbol5 = BufferedChannelKt.POISONED;
if (state$kotlinx_coroutines_core == symbol5) {
return false;
}
symbol6 = BufferedChannelKt.RESUMING_BY_EB;
if (state$kotlinx_coroutines_core == symbol6) {
return true;
}
symbol7 = BufferedChannelKt.RESUMING_BY_RCV;
return state$kotlinx_coroutines_core != symbol7 && j == getReceiversCounter$kotlinx_coroutines_core();
}
}
symbol = BufferedChannelKt.POISONED;
} while (!channelSegment.casState$kotlinx_coroutines_core(i, state$kotlinx_coroutines_core, symbol));
expandBuffer();
return false;
}
public final ChannelSegment findSegmentSend(long j, ChannelSegment channelSegment) {
Object findSegmentInternal;
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = sendSegment$FU;
Function2 function2 = (Function2) BufferedChannelKt.createSegmentFunction();
loop0: while (true) {
findSegmentInternal = ConcurrentLinkedListKt.findSegmentInternal(channelSegment, j, function2);
if (!SegmentOrClosed.m4152isClosedimpl(findSegmentInternal)) {
Segment m4151getSegmentimpl = SegmentOrClosed.m4151getSegmentimpl(findSegmentInternal);
while (true) {
Segment segment = (Segment) atomicReferenceFieldUpdater.get(this);
if (segment.id >= m4151getSegmentimpl.id) {
break loop0;
}
if (!m4151getSegmentimpl.tryIncPointers$kotlinx_coroutines_core()) {
break;
}
if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, segment, m4151getSegmentimpl)) {
if (segment.decPointers$kotlinx_coroutines_core()) {
segment.remove();
}
} else if (m4151getSegmentimpl.decPointers$kotlinx_coroutines_core()) {
m4151getSegmentimpl.remove();
}
}
} else {
break;
}
}
if (SegmentOrClosed.m4152isClosedimpl(findSegmentInternal)) {
completeCloseOrCancel();
if (channelSegment.id * BufferedChannelKt.SEGMENT_SIZE >= getReceiversCounter$kotlinx_coroutines_core()) {
return null;
}
channelSegment.cleanPrev();
return null;
}
ChannelSegment channelSegment2 = (ChannelSegment) SegmentOrClosed.m4151getSegmentimpl(findSegmentInternal);
long j2 = channelSegment2.id;
if (j2 <= j) {
return channelSegment2;
}
int i = BufferedChannelKt.SEGMENT_SIZE;
updateSendersCounterIfLower(j2 * i);
if (channelSegment2.id * i >= getReceiversCounter$kotlinx_coroutines_core()) {
return null;
}
channelSegment2.cleanPrev();
return null;
}
public final ChannelSegment findSegmentReceive(long j, ChannelSegment channelSegment) {
Object findSegmentInternal;
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = receiveSegment$FU;
Function2 function2 = (Function2) BufferedChannelKt.createSegmentFunction();
loop0: while (true) {
findSegmentInternal = ConcurrentLinkedListKt.findSegmentInternal(channelSegment, j, function2);
if (!SegmentOrClosed.m4152isClosedimpl(findSegmentInternal)) {
Segment m4151getSegmentimpl = SegmentOrClosed.m4151getSegmentimpl(findSegmentInternal);
while (true) {
Segment segment = (Segment) atomicReferenceFieldUpdater.get(this);
if (segment.id >= m4151getSegmentimpl.id) {
break loop0;
}
if (!m4151getSegmentimpl.tryIncPointers$kotlinx_coroutines_core()) {
break;
}
if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, segment, m4151getSegmentimpl)) {
if (segment.decPointers$kotlinx_coroutines_core()) {
segment.remove();
}
} else if (m4151getSegmentimpl.decPointers$kotlinx_coroutines_core()) {
m4151getSegmentimpl.remove();
}
}
} else {
break;
}
}
if (SegmentOrClosed.m4152isClosedimpl(findSegmentInternal)) {
completeCloseOrCancel();
if (channelSegment.id * BufferedChannelKt.SEGMENT_SIZE >= getSendersCounter$kotlinx_coroutines_core()) {
return null;
}
channelSegment.cleanPrev();
return null;
}
ChannelSegment channelSegment2 = (ChannelSegment) SegmentOrClosed.m4151getSegmentimpl(findSegmentInternal);
if (!isRendezvousOrUnlimited() && j <= getBufferEndCounter() / BufferedChannelKt.SEGMENT_SIZE) {
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = bufferEndSegment$FU;
while (true) {
Segment segment2 = (Segment) atomicReferenceFieldUpdater2.get(this);
if (segment2.id >= channelSegment2.id || !channelSegment2.tryIncPointers$kotlinx_coroutines_core()) {
break;
}
if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater2, this, segment2, channelSegment2)) {
if (segment2.decPointers$kotlinx_coroutines_core()) {
segment2.remove();
}
} else if (channelSegment2.decPointers$kotlinx_coroutines_core()) {
channelSegment2.remove();
}
}
}
long j2 = channelSegment2.id;
if (j2 <= j) {
return channelSegment2;
}
int i = BufferedChannelKt.SEGMENT_SIZE;
updateReceiversCounterIfLower(j2 * i);
if (channelSegment2.id * i >= getSendersCounter$kotlinx_coroutines_core()) {
return null;
}
channelSegment2.cleanPrev();
return null;
}
public final ChannelSegment findSegmentBufferEnd(long j, ChannelSegment channelSegment, long j2) {
Object findSegmentInternal;
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = bufferEndSegment$FU;
Function2 function2 = (Function2) BufferedChannelKt.createSegmentFunction();
loop0: while (true) {
findSegmentInternal = ConcurrentLinkedListKt.findSegmentInternal(channelSegment, j, function2);
if (!SegmentOrClosed.m4152isClosedimpl(findSegmentInternal)) {
Segment m4151getSegmentimpl = SegmentOrClosed.m4151getSegmentimpl(findSegmentInternal);
while (true) {
Segment segment = (Segment) atomicReferenceFieldUpdater.get(this);
if (segment.id >= m4151getSegmentimpl.id) {
break loop0;
}
if (!m4151getSegmentimpl.tryIncPointers$kotlinx_coroutines_core()) {
break;
}
if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, segment, m4151getSegmentimpl)) {
if (segment.decPointers$kotlinx_coroutines_core()) {
segment.remove();
}
} else if (m4151getSegmentimpl.decPointers$kotlinx_coroutines_core()) {
m4151getSegmentimpl.remove();
}
}
} else {
break;
}
}
if (SegmentOrClosed.m4152isClosedimpl(findSegmentInternal)) {
completeCloseOrCancel();
moveSegmentBufferEndToSpecifiedOrLast(j, channelSegment);
incCompletedExpandBufferAttempts$default(this, 0L, 1, null);
return null;
}
ChannelSegment channelSegment2 = (ChannelSegment) SegmentOrClosed.m4151getSegmentimpl(findSegmentInternal);
long j3 = channelSegment2.id;
if (j3 <= j) {
return channelSegment2;
}
int i = BufferedChannelKt.SEGMENT_SIZE;
if (bufferEnd$FU.compareAndSet(this, j2 + 1, i * j3)) {
incCompletedExpandBufferAttempts((channelSegment2.id * i) - j2);
return null;
}
incCompletedExpandBufferAttempts$default(this, 0L, 1, null);
return null;
}
/* JADX WARN: Code restructure failed: missing block: B:34:0x0011, code lost:
continue;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final void moveSegmentBufferEndToSpecifiedOrLast(long r5, kotlinx.coroutines.channels.ChannelSegment r7) {
/*
r4 = this;
L0:
long r0 = r7.id
int r0 = (r0 > r5 ? 1 : (r0 == r5 ? 0 : -1))
if (r0 >= 0) goto L11
kotlinx.coroutines.internal.ConcurrentLinkedListNode r0 = r7.getNext()
kotlinx.coroutines.channels.ChannelSegment r0 = (kotlinx.coroutines.channels.ChannelSegment) r0
if (r0 != 0) goto Lf
goto L11
Lf:
r7 = r0
goto L0
L11:
boolean r5 = r7.isRemoved()
if (r5 == 0) goto L22
kotlinx.coroutines.internal.ConcurrentLinkedListNode r5 = r7.getNext()
kotlinx.coroutines.channels.ChannelSegment r5 = (kotlinx.coroutines.channels.ChannelSegment) r5
if (r5 != 0) goto L20
goto L22
L20:
r7 = r5
goto L11
L22:
java.util.concurrent.atomic.AtomicReferenceFieldUpdater r5 = kotlinx.coroutines.channels.BufferedChannel.bufferEndSegment$FU
L24:
java.lang.Object r6 = r5.get(r4)
kotlinx.coroutines.internal.Segment r6 = (kotlinx.coroutines.internal.Segment) r6
long r0 = r6.id
long r2 = r7.id
int r0 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
if (r0 < 0) goto L33
goto L49
L33:
boolean r0 = r7.tryIncPointers$kotlinx_coroutines_core()
if (r0 != 0) goto L3a
goto L11
L3a:
boolean r0 = androidx.concurrent.futures.AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(r5, r4, r6, r7)
if (r0 == 0) goto L4a
boolean r5 = r6.decPointers$kotlinx_coroutines_core()
if (r5 == 0) goto L49
r6.remove()
L49:
return
L4a:
boolean r6 = r7.decPointers$kotlinx_coroutines_core()
if (r6 == 0) goto L24
r7.remove()
goto L24
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.channels.BufferedChannel.moveSegmentBufferEndToSpecifiedOrLast(long, kotlinx.coroutines.channels.ChannelSegment):void");
}
public final void updateSendersCounterIfLower(long j) {
long j2;
long constructSendersAndCloseStatus;
AtomicLongFieldUpdater atomicLongFieldUpdater = sendersAndCloseStatus$FU;
do {
j2 = atomicLongFieldUpdater.get(this);
long j3 = 1152921504606846975L & j2;
if (j3 >= j) {
return;
} else {
constructSendersAndCloseStatus = BufferedChannelKt.constructSendersAndCloseStatus(j3, (int) (j2 >> 60));
}
} while (!sendersAndCloseStatus$FU.compareAndSet(this, j2, constructSendersAndCloseStatus));
}
public final void updateReceiversCounterIfLower(long j) {
long j2;
AtomicLongFieldUpdater atomicLongFieldUpdater = receivers$FU;
do {
j2 = atomicLongFieldUpdater.get(this);
if (j2 >= j) {
return;
}
} while (!receivers$FU.compareAndSet(this, j2, j));
}
/* JADX WARN: Code restructure failed: missing block: B:91:0x01b4, code lost:
r3 = (kotlinx.coroutines.channels.ChannelSegment) r3.getNext();
*/
/* JADX WARN: Code restructure failed: missing block: B:92:0x01bb, code lost:
if (r3 != null) goto L85;
*/
/* JADX WARN: Multi-variable type inference failed */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public java.lang.String toString() {
/*
Method dump skipped, instructions count: 486
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.channels.BufferedChannel.toString():java.lang.String");
}
}