Files
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

573 lines
22 KiB
Java

package kotlinx.coroutines.flow;
import kotlin.Result;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugProbesKt;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.CancellableContinuationImpl;
import kotlinx.coroutines.CancellableContinuationKt;
import kotlinx.coroutines.DisposableHandle;
import kotlinx.coroutines.channels.BufferOverflow;
import kotlinx.coroutines.flow.internal.AbstractSharedFlow;
import kotlinx.coroutines.flow.internal.AbstractSharedFlowKt;
import kotlinx.coroutines.flow.internal.FusibleFlow;
/* loaded from: classes5.dex */
public class SharedFlowImpl extends AbstractSharedFlow implements MutableSharedFlow, Flow, FusibleFlow {
public Object[] buffer;
public final int bufferCapacity;
public int bufferSize;
public long minCollectorIndex;
public final BufferOverflow onBufferOverflow;
public int queueSize;
public final int replay;
public long replayIndex;
public /* synthetic */ class WhenMappings {
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
static {
int[] iArr = new int[BufferOverflow.values().length];
try {
iArr[BufferOverflow.SUSPEND.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
iArr[BufferOverflow.DROP_LATEST.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
iArr[BufferOverflow.DROP_OLDEST.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
$EnumSwitchMapping$0 = iArr;
}
}
@Override // kotlinx.coroutines.flow.SharedFlow, kotlinx.coroutines.flow.Flow
public Object collect(FlowCollector flowCollector, Continuation continuation) {
return collect$suspendImpl(this, flowCollector, continuation);
}
@Override // kotlinx.coroutines.flow.MutableSharedFlow, kotlinx.coroutines.flow.FlowCollector
public Object emit(Object obj, Continuation continuation) {
return emit$suspendImpl(this, obj, continuation);
}
public final int getTotalSize() {
return this.bufferSize + this.queueSize;
}
public final long updateNewCollectorIndexLocked$kotlinx_coroutines_core() {
long j = this.replayIndex;
if (j < this.minCollectorIndex) {
this.minCollectorIndex = j;
}
return j;
}
public final void cancelEmitter(Emitter emitter) {
Object bufferAt;
synchronized (this) {
if (emitter.index < getHead()) {
return;
}
Object[] objArr = this.buffer;
Intrinsics.checkNotNull(objArr);
bufferAt = SharedFlowKt.getBufferAt(objArr, emitter.index);
if (bufferAt != emitter) {
return;
}
SharedFlowKt.setBufferAt(objArr, emitter.index, SharedFlowKt.NO_VALUE);
cleanupTailLocked();
Unit unit = Unit.INSTANCE;
}
}
@Override // kotlinx.coroutines.flow.MutableSharedFlow
public void resetReplayCache() {
synchronized (this) {
updateBufferLocked(getBufferEndIndex(), this.minCollectorIndex, getBufferEndIndex(), getQueueEndIndex());
Unit unit = Unit.INSTANCE;
}
}
/* JADX WARN: Code restructure failed: missing block: B:3:0x0006, code lost:
r0 = r8.slots;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final void correctCollectorIndexesOnDropOldest(long r9) {
/*
r8 = this;
int r0 = kotlinx.coroutines.flow.internal.AbstractSharedFlow.access$getNCollectors(r8)
if (r0 == 0) goto L27
kotlinx.coroutines.flow.internal.AbstractSharedFlowSlot[] r0 = kotlinx.coroutines.flow.internal.AbstractSharedFlow.access$getSlots(r8)
if (r0 == 0) goto L27
int r1 = r0.length
r2 = 0
Le:
if (r2 >= r1) goto L27
r3 = r0[r2]
if (r3 == 0) goto L24
kotlinx.coroutines.flow.SharedFlowSlot r3 = (kotlinx.coroutines.flow.SharedFlowSlot) r3
long r4 = r3.index
r6 = 0
int r6 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1))
if (r6 < 0) goto L24
int r4 = (r4 > r9 ? 1 : (r4 == r9 ? 0 : -1))
if (r4 >= 0) goto L24
r3.index = r9
L24:
int r2 = r2 + 1
goto Le
L27:
r8.minCollectorIndex = r9
return
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.flow.SharedFlowImpl.correctCollectorIndexesOnDropOldest(long):void");
}
public SharedFlowImpl(int i, int i2, BufferOverflow bufferOverflow) {
this.replay = i;
this.bufferCapacity = i2;
this.onBufferOverflow = bufferOverflow;
}
public final Object awaitValue(SharedFlowSlot sharedFlowSlot, Continuation continuation) {
Continuation intercepted;
Object coroutine_suspended;
Object coroutine_suspended2;
intercepted = IntrinsicsKt__IntrinsicsJvmKt.intercepted(continuation);
CancellableContinuationImpl cancellableContinuationImpl = new CancellableContinuationImpl(intercepted, 1);
cancellableContinuationImpl.initCancellability();
synchronized (this) {
try {
if (tryPeekLocked(sharedFlowSlot) >= 0) {
Result.Companion companion = Result.Companion;
cancellableContinuationImpl.resumeWith(Result.m4060constructorimpl(Unit.INSTANCE));
} else {
sharedFlowSlot.cont = cancellableContinuationImpl;
}
Unit unit = Unit.INSTANCE;
} catch (Throwable th) {
throw th;
}
}
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 Object emitSuspend(Object obj, Continuation continuation) {
Continuation intercepted;
Continuation[] continuationArr;
Emitter emitter;
Object coroutine_suspended;
Object coroutine_suspended2;
intercepted = IntrinsicsKt__IntrinsicsJvmKt.intercepted(continuation);
CancellableContinuationImpl cancellableContinuationImpl = new CancellableContinuationImpl(intercepted, 1);
cancellableContinuationImpl.initCancellability();
Continuation[] continuationArr2 = AbstractSharedFlowKt.EMPTY_RESUMES;
synchronized (this) {
try {
if (tryEmitLocked(obj)) {
Result.Companion companion = Result.Companion;
cancellableContinuationImpl.resumeWith(Result.m4060constructorimpl(Unit.INSTANCE));
continuationArr = findSlotsToResumeLocked(continuationArr2);
emitter = null;
} else {
Emitter emitter2 = new Emitter(this, getTotalSize() + getHead(), obj, cancellableContinuationImpl);
enqueueLocked(emitter2);
this.queueSize++;
if (this.bufferCapacity == 0) {
continuationArr2 = findSlotsToResumeLocked(continuationArr2);
}
continuationArr = continuationArr2;
emitter = emitter2;
}
} catch (Throwable th) {
throw th;
}
}
if (emitter != null) {
CancellableContinuationKt.disposeOnCancellation(cancellableContinuationImpl, emitter);
}
for (Continuation continuation2 : continuationArr) {
if (continuation2 != null) {
Result.Companion companion2 = Result.Companion;
continuation2.resumeWith(Result.m4060constructorimpl(Unit.INSTANCE));
}
}
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 long getHead() {
return Math.min(this.minCollectorIndex, this.replayIndex);
}
public final int getReplaySize() {
return (int) ((getHead() + this.bufferSize) - this.replayIndex);
}
public final long getBufferEndIndex() {
return getHead() + this.bufferSize;
}
public final long getQueueEndIndex() {
return getHead() + this.bufferSize + this.queueSize;
}
public final Object getLastReplayedLocked() {
Object bufferAt;
Object[] objArr = this.buffer;
Intrinsics.checkNotNull(objArr);
bufferAt = SharedFlowKt.getBufferAt(objArr, (this.replayIndex + getReplaySize()) - 1);
return bufferAt;
}
/* JADX WARN: Can't wrap try/catch for region: R(10:0|1|(2:3|(7:5|6|(3:(6:(1:(1:11)(2:41|42))(1:43)|12|13|14|15|(3:16|(3:28|29|(2:31|32)(1:33))(4:18|(1:20)|21|(2:23|24)(1:26))|27))(4:44|45|46|47)|37|38)(5:53|54|55|(2:57|(1:59))|61)|48|49|15|(3:16|(0)(0)|27)))|64|6|(0)(0)|48|49|15|(3:16|(0)(0)|27)) */
/* JADX WARN: Code restructure failed: missing block: B:35:0x00c2, code lost:
r10 = move-exception;
*/
/* JADX WARN: Code restructure failed: missing block: B:36:0x00c3, code lost:
r5 = r8;
r8 = r10;
*/
/* JADX WARN: Removed duplicated region for block: B:18:0x00c6 A[SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:28:0x00b1 A[SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:53:0x0076 */
/* JADX WARN: Removed duplicated region for block: B:8:0x0025 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static /* synthetic */ java.lang.Object collect$suspendImpl(kotlinx.coroutines.flow.SharedFlowImpl r8, kotlinx.coroutines.flow.FlowCollector r9, kotlin.coroutines.Continuation r10) {
/*
Method dump skipped, instructions count: 224
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(kotlinx.coroutines.flow.SharedFlowImpl, kotlinx.coroutines.flow.FlowCollector, kotlin.coroutines.Continuation):java.lang.Object");
}
@Override // kotlinx.coroutines.flow.MutableSharedFlow
public boolean tryEmit(Object obj) {
int i;
boolean z;
Continuation[] continuationArr = AbstractSharedFlowKt.EMPTY_RESUMES;
synchronized (this) {
if (tryEmitLocked(obj)) {
continuationArr = findSlotsToResumeLocked(continuationArr);
z = true;
} else {
z = false;
}
}
for (Continuation continuation : continuationArr) {
if (continuation != null) {
Result.Companion companion = Result.Companion;
continuation.resumeWith(Result.m4060constructorimpl(Unit.INSTANCE));
}
}
return z;
}
public static /* synthetic */ Object emit$suspendImpl(SharedFlowImpl sharedFlowImpl, Object obj, Continuation continuation) {
Object coroutine_suspended;
if (sharedFlowImpl.tryEmit(obj)) {
return Unit.INSTANCE;
}
Object emitSuspend = sharedFlowImpl.emitSuspend(obj, continuation);
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
return emitSuspend == coroutine_suspended ? emitSuspend : Unit.INSTANCE;
}
public final boolean tryEmitLocked(Object obj) {
if (getNCollectors() == 0) {
return tryEmitNoCollectorsLocked(obj);
}
if (this.bufferSize >= this.bufferCapacity && this.minCollectorIndex <= this.replayIndex) {
int i = WhenMappings.$EnumSwitchMapping$0[this.onBufferOverflow.ordinal()];
if (i == 1) {
return false;
}
if (i == 2) {
return true;
}
}
enqueueLocked(obj);
int i2 = this.bufferSize + 1;
this.bufferSize = i2;
if (i2 > this.bufferCapacity) {
dropOldestLocked();
}
if (getReplaySize() > this.replay) {
updateBufferLocked(this.replayIndex + 1, this.minCollectorIndex, getBufferEndIndex(), getQueueEndIndex());
}
return true;
}
public final boolean tryEmitNoCollectorsLocked(Object obj) {
if (this.replay == 0) {
return true;
}
enqueueLocked(obj);
int i = this.bufferSize + 1;
this.bufferSize = i;
if (i > this.replay) {
dropOldestLocked();
}
this.minCollectorIndex = getHead() + this.bufferSize;
return true;
}
public final void dropOldestLocked() {
Object[] objArr = this.buffer;
Intrinsics.checkNotNull(objArr);
SharedFlowKt.setBufferAt(objArr, getHead(), null);
this.bufferSize--;
long head = getHead() + 1;
if (this.replayIndex < head) {
this.replayIndex = head;
}
if (this.minCollectorIndex < head) {
correctCollectorIndexesOnDropOldest(head);
}
}
public final void enqueueLocked(Object obj) {
int totalSize = getTotalSize();
Object[] objArr = this.buffer;
if (objArr == null) {
objArr = growBuffer(null, 0, 2);
} else if (totalSize >= objArr.length) {
objArr = growBuffer(objArr, totalSize, objArr.length * 2);
}
SharedFlowKt.setBufferAt(objArr, getHead() + totalSize, obj);
}
public final Object[] growBuffer(Object[] objArr, int i, int i2) {
Object bufferAt;
if (i2 <= 0) {
throw new IllegalStateException("Buffer size overflow".toString());
}
Object[] objArr2 = new Object[i2];
this.buffer = objArr2;
if (objArr == null) {
return objArr2;
}
long head = getHead();
for (int i3 = 0; i3 < i; i3++) {
long j = i3 + head;
bufferAt = SharedFlowKt.getBufferAt(objArr, j);
SharedFlowKt.setBufferAt(objArr2, j, bufferAt);
}
return objArr2;
}
/* JADX WARN: Code restructure failed: missing block: B:13:0x0024, code lost:
r4 = r21.slots;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final kotlin.coroutines.Continuation[] updateCollectorIndexLocked$kotlinx_coroutines_core(long r22) {
/*
Method dump skipped, instructions count: 269
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.flow.SharedFlowImpl.updateCollectorIndexLocked$kotlinx_coroutines_core(long):kotlin.coroutines.Continuation[]");
}
public final void updateBufferLocked(long j, long j2, long j3, long j4) {
long min = Math.min(j2, j);
for (long head = getHead(); head < min; head++) {
Object[] objArr = this.buffer;
Intrinsics.checkNotNull(objArr);
SharedFlowKt.setBufferAt(objArr, head, null);
}
this.replayIndex = j;
this.minCollectorIndex = j2;
this.bufferSize = (int) (j3 - min);
this.queueSize = (int) (j4 - j3);
}
public final void cleanupTailLocked() {
Object bufferAt;
if (this.bufferCapacity != 0 || this.queueSize > 1) {
Object[] objArr = this.buffer;
Intrinsics.checkNotNull(objArr);
while (this.queueSize > 0) {
bufferAt = SharedFlowKt.getBufferAt(objArr, (getHead() + getTotalSize()) - 1);
if (bufferAt != SharedFlowKt.NO_VALUE) {
return;
}
this.queueSize--;
SharedFlowKt.setBufferAt(objArr, getHead() + getTotalSize(), null);
}
}
}
public final Object tryTakeValue(SharedFlowSlot sharedFlowSlot) {
Object obj;
Continuation[] continuationArr = AbstractSharedFlowKt.EMPTY_RESUMES;
synchronized (this) {
try {
long tryPeekLocked = tryPeekLocked(sharedFlowSlot);
if (tryPeekLocked < 0) {
obj = SharedFlowKt.NO_VALUE;
} else {
long j = sharedFlowSlot.index;
Object peekedValueLockedAt = getPeekedValueLockedAt(tryPeekLocked);
sharedFlowSlot.index = tryPeekLocked + 1;
continuationArr = updateCollectorIndexLocked$kotlinx_coroutines_core(j);
obj = peekedValueLockedAt;
}
} catch (Throwable th) {
throw th;
}
}
for (Continuation continuation : continuationArr) {
if (continuation != null) {
Result.Companion companion = Result.Companion;
continuation.resumeWith(Result.m4060constructorimpl(Unit.INSTANCE));
}
}
return obj;
}
public final long tryPeekLocked(SharedFlowSlot sharedFlowSlot) {
long j = sharedFlowSlot.index;
if (j < getBufferEndIndex()) {
return j;
}
if (this.bufferCapacity <= 0 && j <= getHead() && this.queueSize != 0) {
return j;
}
return -1L;
}
public final Object getPeekedValueLockedAt(long j) {
Object bufferAt;
Object[] objArr = this.buffer;
Intrinsics.checkNotNull(objArr);
bufferAt = SharedFlowKt.getBufferAt(objArr, j);
return bufferAt instanceof Emitter ? ((Emitter) bufferAt).value : bufferAt;
}
/* JADX WARN: Code restructure failed: missing block: B:3:0x0007, code lost:
r1 = r10.slots;
*/
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r11v6, types: [java.lang.Object, java.lang.Object[]] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final kotlin.coroutines.Continuation[] findSlotsToResumeLocked(kotlin.coroutines.Continuation[] r11) {
/*
r10 = this;
int r0 = r11.length
int r1 = kotlinx.coroutines.flow.internal.AbstractSharedFlow.access$getNCollectors(r10)
if (r1 == 0) goto L47
kotlinx.coroutines.flow.internal.AbstractSharedFlowSlot[] r1 = kotlinx.coroutines.flow.internal.AbstractSharedFlow.access$getSlots(r10)
if (r1 == 0) goto L47
int r2 = r1.length
r3 = 0
Lf:
if (r3 >= r2) goto L47
r4 = r1[r3]
if (r4 == 0) goto L44
kotlinx.coroutines.flow.SharedFlowSlot r4 = (kotlinx.coroutines.flow.SharedFlowSlot) r4
kotlin.coroutines.Continuation r5 = r4.cont
if (r5 != 0) goto L1c
goto L44
L1c:
long r6 = r10.tryPeekLocked(r4)
r8 = 0
int r6 = (r6 > r8 ? 1 : (r6 == r8 ? 0 : -1))
if (r6 < 0) goto L44
int r6 = r11.length
if (r0 < r6) goto L39
int r6 = r11.length
r7 = 2
int r6 = r6 * r7
int r6 = java.lang.Math.max(r7, r6)
java.lang.Object[] r11 = java.util.Arrays.copyOf(r11, r6)
java.lang.String r6 = "copyOf(this, newSize)"
kotlin.jvm.internal.Intrinsics.checkNotNullExpressionValue(r11, r6)
L39:
r6 = r11
kotlin.coroutines.Continuation[] r6 = (kotlin.coroutines.Continuation[]) r6
int r7 = r0 + 1
r6[r0] = r5
r0 = 0
r4.cont = r0
r0 = r7
L44:
int r3 = r3 + 1
goto Lf
L47:
kotlin.coroutines.Continuation[] r11 = (kotlin.coroutines.Continuation[]) r11
return r11
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.flow.SharedFlowImpl.findSlotsToResumeLocked(kotlin.coroutines.Continuation[]):kotlin.coroutines.Continuation[]");
}
@Override // kotlinx.coroutines.flow.internal.AbstractSharedFlow
public SharedFlowSlot createSlot() {
return new SharedFlowSlot();
}
@Override // kotlinx.coroutines.flow.internal.AbstractSharedFlow
public SharedFlowSlot[] createSlotArray(int i) {
return new SharedFlowSlot[i];
}
@Override // kotlinx.coroutines.flow.internal.FusibleFlow
public Flow fuse(CoroutineContext coroutineContext, int i, BufferOverflow bufferOverflow) {
return SharedFlowKt.fuseSharedFlow(this, coroutineContext, i, bufferOverflow);
}
public static final class Emitter implements DisposableHandle {
public final Continuation cont;
public final SharedFlowImpl flow;
public long index;
public final Object value;
public Emitter(SharedFlowImpl sharedFlowImpl, long j, Object obj, Continuation continuation) {
this.flow = sharedFlowImpl;
this.index = j;
this.value = obj;
this.cont = continuation;
}
@Override // kotlinx.coroutines.DisposableHandle
public void dispose() {
this.flow.cancelEmitter(this);
}
}
}