ADD week 5

This commit is contained in:
2025-03-31 16:33:42 +02:00
parent 86f265f22d
commit bf645048e6
4927 changed files with 544053 additions and 0 deletions

View File

@ -0,0 +1,63 @@
package kotlinx.coroutines.sync;
import kotlin.Deprecated;
import kotlin.DeprecationLevel;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlinx.coroutines.selects.SelectClause2;
/* compiled from: Mutex.kt */
@Metadata(d1 = {"\u0000\"\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\u0002\n\u0002\b\u0004\bf\u0018\u00002\u00020\u0001J\u0010\u0010\u000b\u001a\u00020\u00032\u0006\u0010\f\u001a\u00020\u0001H&J\u001d\u0010\r\u001a\u00020\u000e2\n\b\u0002\u0010\f\u001a\u0004\u0018\u00010\u0001H¦@ø\u0001\u0000¢\u0006\u0002\u0010\u000fJ\u0014\u0010\u0010\u001a\u00020\u00032\n\b\u0002\u0010\f\u001a\u0004\u0018\u00010\u0001H&J\u0014\u0010\u0011\u001a\u00020\u000e2\n\b\u0002\u0010\f\u001a\u0004\u0018\u00010\u0001H&R\u0012\u0010\u0002\u001a\u00020\u0003X¦\u0004¢\u0006\u0006\u001a\u0004\b\u0002\u0010\u0004R(\u0010\u0005\u001a\u0010\u0012\u0006\u0012\u0004\u0018\u00010\u0001\u0012\u0004\u0012\u00020\u00000\u00068&X§\u0004¢\u0006\f\u0012\u0004\b\u0007\u0010\b\u001a\u0004\b\t\u0010\n\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\u0012"}, d2 = {"Lkotlinx/coroutines/sync/Mutex;", "", "isLocked", "", "()Z", "onLock", "Lkotlinx/coroutines/selects/SelectClause2;", "getOnLock$annotations", "()V", "getOnLock", "()Lkotlinx/coroutines/selects/SelectClause2;", "holdsLock", "owner", "lock", "", "(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "tryLock", "unlock", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public interface Mutex {
SelectClause2<Object, Mutex> getOnLock();
boolean holdsLock(Object owner);
boolean isLocked();
Object lock(Object obj, Continuation<? super Unit> continuation);
boolean tryLock(Object owner);
void unlock(Object owner);
/* compiled from: Mutex.kt */
@Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
public static final class DefaultImpls {
@Deprecated(level = DeprecationLevel.WARNING, message = "Mutex.onLock deprecated without replacement. For additional details please refer to #2794")
public static /* synthetic */ void getOnLock$annotations() {
}
public static /* synthetic */ boolean tryLock$default(Mutex mutex, Object obj, int i, Object obj2) {
if (obj2 != null) {
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: tryLock");
}
if ((i & 1) != 0) {
obj = null;
}
return mutex.tryLock(obj);
}
public static /* synthetic */ Object lock$default(Mutex mutex, Object obj, Continuation continuation, int i, Object obj2) {
if (obj2 != null) {
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: lock");
}
if ((i & 1) != 0) {
obj = null;
}
return mutex.lock(obj, continuation);
}
public static /* synthetic */ void unlock$default(Mutex mutex, Object obj, int i, Object obj2) {
if (obj2 != null) {
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: unlock");
}
if ((i & 1) != 0) {
obj = null;
}
mutex.unlock(obj);
}
}
}

View File

@ -0,0 +1,29 @@
package kotlinx.coroutines.sync;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function3;
import kotlin.jvm.internal.FunctionReferenceImpl;
import kotlinx.coroutines.selects.SelectInstance;
/* compiled from: Mutex.kt */
@Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
/* synthetic */ class MutexImpl$onLock$1 extends FunctionReferenceImpl implements Function3<MutexImpl, SelectInstance<?>, Object, Unit> {
public static final MutexImpl$onLock$1 INSTANCE = new MutexImpl$onLock$1();
MutexImpl$onLock$1() {
super(3, MutexImpl.class, "onLockRegFunction", "onLockRegFunction(Lkotlinx/coroutines/selects/SelectInstance;Ljava/lang/Object;)V", 0);
}
@Override // kotlin.jvm.functions.Function3
public /* bridge */ /* synthetic */ Unit invoke(MutexImpl mutexImpl, SelectInstance<?> selectInstance, Object obj) {
invoke2(mutexImpl, selectInstance, obj);
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2(MutexImpl mutexImpl, SelectInstance<?> selectInstance, Object obj) {
mutexImpl.onLockRegFunction(selectInstance, obj);
}
}

View File

@ -0,0 +1,21 @@
package kotlinx.coroutines.sync;
import kotlin.Metadata;
import kotlin.jvm.functions.Function3;
import kotlin.jvm.internal.FunctionReferenceImpl;
/* compiled from: Mutex.kt */
@Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
/* synthetic */ class MutexImpl$onLock$2 extends FunctionReferenceImpl implements Function3<MutexImpl, Object, Object, Object> {
public static final MutexImpl$onLock$2 INSTANCE = new MutexImpl$onLock$2();
MutexImpl$onLock$2() {
super(3, MutexImpl.class, "onLockProcessResult", "onLockProcessResult(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 0);
}
@Override // kotlin.jvm.functions.Function3
public final Object invoke(MutexImpl mutexImpl, Object obj, Object obj2) {
return mutexImpl.onLockProcessResult(obj, obj2);
}
}

View File

@ -0,0 +1,460 @@
package kotlinx.coroutines.sync;
import androidx.concurrent.futures.AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugProbesKt;
import kotlin.jvm.Volatile;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function3;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.TypeIntrinsics;
import kotlinx.coroutines.CancellableContinuation;
import kotlinx.coroutines.CancellableContinuationImpl;
import kotlinx.coroutines.CancellableContinuationKt;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.DebugKt;
import kotlinx.coroutines.DebugStringsKt;
import kotlinx.coroutines.DisposableHandle;
import kotlinx.coroutines.Waiter;
import kotlinx.coroutines.internal.Segment;
import kotlinx.coroutines.internal.Symbol;
import kotlinx.coroutines.selects.SelectClause2;
import kotlinx.coroutines.selects.SelectClause2Impl;
import kotlinx.coroutines.selects.SelectInstance;
import kotlinx.coroutines.selects.SelectInstanceInternal;
import kotlinx.coroutines.sync.MutexImpl;
/* compiled from: Mutex.kt */
@Metadata(d1 = {"\u0000\\\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0010\u0003\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0004\b\u0010\u0018\u00002\u00020\u00012\u00020\u0002:\u0002*+B\r\u0012\u0006\u0010\u0003\u001a\u00020\u0004¢\u0006\u0002\u0010\u0005J\u0010\u0010\u001d\u001a\u00020\u00042\u0006\u0010\u001b\u001a\u00020\nH\u0016J\u001b\u0010\u001e\u001a\u00020\u00192\b\u0010\u001b\u001a\u0004\u0018\u00010\nH\u0096@ø\u0001\u0000¢\u0006\u0002\u0010\u001fJ\u001b\u0010 \u001a\u00020\u00192\b\u0010\u001b\u001a\u0004\u0018\u00010\nH\u0082@ø\u0001\u0000¢\u0006\u0002\u0010\u001fJ\u001e\u0010!\u001a\u0004\u0018\u00010\n2\b\u0010\u001b\u001a\u0004\u0018\u00010\n2\b\u0010\"\u001a\u0004\u0018\u00010\nH\u0014J\u001e\u0010#\u001a\u00020\u00192\n\u0010\u0014\u001a\u0006\u0012\u0002\b\u00030\u00112\b\u0010\u001b\u001a\u0004\u0018\u00010\nH\u0014J\b\u0010$\u001a\u00020%H\u0016J\u0012\u0010&\u001a\u00020\u00042\b\u0010\u001b\u001a\u0004\u0018\u00010\nH\u0016J\u0012\u0010'\u001a\u00020(2\b\u0010\u001b\u001a\u0004\u0018\u00010\nH\u0002J\u0012\u0010)\u001a\u00020\u00192\b\u0010\u001b\u001a\u0004\u0018\u00010\nH\u0016R\u0014\u0010\u0006\u001a\u00020\u00048VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u0006\u0010\u0007R(\u0010\b\u001a\u0010\u0012\u0006\u0012\u0004\u0018\u00010\n\u0012\u0004\u0012\u00020\u00020\t8VX\u0096\u0004¢\u0006\f\u0012\u0004\b\u000b\u0010\f\u001a\u0004\b\r\u0010\u000eRk\u0010\u000f\u001a_\u0012\u0017\u0012\u0015\u0012\u0002\b\u00030\u0011¢\u0006\f\b\u0012\u0012\b\b\u0013\u0012\u0004\b\b(\u0014\u0012\u0015\u0012\u0013\u0018\u00010\\u0006\f\b\u0012\u0012\b\b\u0013\u0012\u0004\b\b(\u0015\u0012\u0015\u0012\u0013\u0018\u00010\\u0006\f\b\u0012\u0012\b\b\u0013\u0012\u0004\b\b(\u0016\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020\u0018\u0012\u0004\u0012\u00020\u00190\u00170\u0010j\u0002`\u001aX\u0082\u0004¢\u0006\u0002\n\u0000R\u0011\u0010\u001b\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\n0\u001cX\u0082\u0004\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006,"}, d2 = {"Lkotlinx/coroutines/sync/MutexImpl;", "Lkotlinx/coroutines/sync/SemaphoreImpl;", "Lkotlinx/coroutines/sync/Mutex;", "locked", "", "(Z)V", "isLocked", "()Z", "onLock", "Lkotlinx/coroutines/selects/SelectClause2;", "", "getOnLock$annotations", "()V", "getOnLock", "()Lkotlinx/coroutines/selects/SelectClause2;", "onSelectCancellationUnlockConstructor", "Lkotlin/Function3;", "Lkotlinx/coroutines/selects/SelectInstance;", "Lkotlin/ParameterName;", "name", "select", "param", "internalResult", "Lkotlin/Function1;", "", "", "Lkotlinx/coroutines/selects/OnCancellationConstructor;", "owner", "Lkotlinx/atomicfu/AtomicRef;", "holdsLock", "lock", "(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "lockSuspend", "onLockProcessResult", "result", "onLockRegFunction", "toString", "", "tryLock", "tryLockImpl", "", "unlock", "CancellableContinuationWithOwner", "SelectInstanceWithOwner", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public class MutexImpl extends SemaphoreImpl implements Mutex {
private static final AtomicReferenceFieldUpdater owner$FU = AtomicReferenceFieldUpdater.newUpdater(MutexImpl.class, Object.class, "owner");
private final Function3<SelectInstance<?>, Object, Object, Function1<Throwable, Unit>> onSelectCancellationUnlockConstructor;
@Volatile
private volatile Object owner;
public static /* synthetic */ void getOnLock$annotations() {
}
@Override // kotlinx.coroutines.sync.Mutex
public Object lock(Object obj, Continuation<? super Unit> continuation) {
return lock$suspendImpl(this, obj, continuation);
}
/* JADX WARN: Multi-variable type inference failed */
public MutexImpl(boolean z) {
super(1, z ? 1 : 0);
this.owner = z ? null : MutexKt.NO_OWNER;
this.onSelectCancellationUnlockConstructor = new Function3<SelectInstance<?>, Object, Object, Function1<? super Throwable, ? extends Unit>>() { // from class: kotlinx.coroutines.sync.MutexImpl$onSelectCancellationUnlockConstructor$1
{
super(3);
}
@Override // kotlin.jvm.functions.Function3
public final Function1<Throwable, Unit> invoke(SelectInstance<?> selectInstance, final Object obj, Object obj2) {
final MutexImpl mutexImpl = MutexImpl.this;
return new Function1<Throwable, Unit>() { // from class: kotlinx.coroutines.sync.MutexImpl$onSelectCancellationUnlockConstructor$1.1
/* 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 */ Unit invoke(Throwable th) {
invoke2(th);
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2(Throwable th) {
MutexImpl.this.unlock(obj);
}
};
}
};
}
@Override // kotlinx.coroutines.sync.Mutex
public boolean isLocked() {
return getAvailablePermits() == 0;
}
@Override // kotlinx.coroutines.sync.Mutex
public boolean holdsLock(Object owner) {
Symbol symbol;
while (isLocked()) {
Object obj = owner$FU.get(this);
symbol = MutexKt.NO_OWNER;
if (obj != symbol) {
return obj == owner;
}
}
return false;
}
static /* synthetic */ Object lock$suspendImpl(MutexImpl mutexImpl, Object obj, Continuation<? super Unit> continuation) {
Object lockSuspend;
return (!mutexImpl.tryLock(obj) && (lockSuspend = mutexImpl.lockSuspend(obj, continuation)) == IntrinsicsKt.getCOROUTINE_SUSPENDED()) ? lockSuspend : Unit.INSTANCE;
}
@Override // kotlinx.coroutines.sync.Mutex
public boolean tryLock(Object owner) {
int tryLockImpl = tryLockImpl(owner);
if (tryLockImpl == 0) {
return true;
}
if (tryLockImpl == 1) {
return false;
}
if (tryLockImpl == 2) {
throw new IllegalStateException(("This mutex is already locked by the specified owner: " + owner).toString());
}
throw new IllegalStateException("unexpected".toString());
}
private final int tryLockImpl(Object owner) {
Symbol symbol;
while (!tryAcquire()) {
if (owner == null) {
return 1;
}
if (holdsLock(owner)) {
return 2;
}
if (isLocked()) {
return 1;
}
}
if (DebugKt.getASSERTIONS_ENABLED()) {
Object obj = owner$FU.get(this);
symbol = MutexKt.NO_OWNER;
if (obj != symbol) {
throw new AssertionError();
}
}
owner$FU.set(this, owner);
return 0;
}
@Override // kotlinx.coroutines.sync.Mutex
public void unlock(Object owner) {
Symbol symbol;
Symbol symbol2;
while (isLocked()) {
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = owner$FU;
Object obj = atomicReferenceFieldUpdater.get(this);
symbol = MutexKt.NO_OWNER;
if (obj != symbol) {
if (obj != owner && owner != null) {
throw new IllegalStateException(("This mutex is locked by " + obj + ", but " + owner + " is expected").toString());
}
symbol2 = MutexKt.NO_OWNER;
if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, obj, symbol2)) {
release();
return;
}
}
}
throw new IllegalStateException("This mutex is not locked".toString());
}
@Override // kotlinx.coroutines.sync.Mutex
public SelectClause2<Object, Mutex> getOnLock() {
MutexImpl$onLock$1 mutexImpl$onLock$1 = MutexImpl$onLock$1.INSTANCE;
Intrinsics.checkNotNull(mutexImpl$onLock$1, "null cannot be cast to non-null type kotlin.Function3<@[ParameterName(name = 'clauseObject')] kotlin.Any, @[ParameterName(name = 'select')] kotlinx.coroutines.selects.SelectInstance<*>, @[ParameterName(name = 'param')] kotlin.Any?, kotlin.Unit>{ kotlinx.coroutines.selects.SelectKt.RegistrationFunction }");
Function3 function3 = (Function3) TypeIntrinsics.beforeCheckcastToFunctionOfArity(mutexImpl$onLock$1, 3);
MutexImpl$onLock$2 mutexImpl$onLock$2 = MutexImpl$onLock$2.INSTANCE;
Intrinsics.checkNotNull(mutexImpl$onLock$2, "null cannot be cast to non-null type kotlin.Function3<@[ParameterName(name = 'clauseObject')] kotlin.Any, @[ParameterName(name = 'param')] kotlin.Any?, @[ParameterName(name = 'clauseResult')] kotlin.Any?, kotlin.Any?>{ kotlinx.coroutines.selects.SelectKt.ProcessResultFunction }");
return new SelectClause2Impl(this, function3, (Function3) TypeIntrinsics.beforeCheckcastToFunctionOfArity(mutexImpl$onLock$2, 3), this.onSelectCancellationUnlockConstructor);
}
protected void onLockRegFunction(SelectInstance<?> select, Object owner) {
Symbol symbol;
if (owner != null && holdsLock(owner)) {
symbol = MutexKt.ON_LOCK_ALREADY_LOCKED_BY_OWNER;
select.selectInRegistrationPhase(symbol);
} else {
Intrinsics.checkNotNull(select, "null cannot be cast to non-null type kotlinx.coroutines.selects.SelectInstanceInternal<*>");
onAcquireRegFunction(new SelectInstanceWithOwner((SelectInstanceInternal) select, owner), owner);
}
}
protected Object onLockProcessResult(Object owner, Object result) {
Symbol symbol;
symbol = MutexKt.ON_LOCK_ALREADY_LOCKED_BY_OWNER;
if (!Intrinsics.areEqual(result, symbol)) {
return this;
}
throw new IllegalStateException(("This mutex is already locked by the specified owner: " + owner).toString());
}
/* compiled from: Mutex.kt */
@Metadata(d1 = {"\u0000f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0005\n\u0002\u0010\u0003\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0082\u0004\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u00012\u00020\u0003B\u001d\u0012\f\u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00020\u0005\u0012\b\u0010\u0006\u001a\u0004\u0018\u00010\u0007¢\u0006\u0002\u0010\bJ\u0015\u0010\u0012\u001a\u00020\u000e2\n\b\u0002\u0010\u0013\u001a\u0004\u0018\u00010\u0014H\u0096\u0001J\u0011\u0010\u0015\u001a\u00020\u00022\u0006\u0010\u0016\u001a\u00020\u0007H\u0097\u0001J\t\u0010\u0017\u001a\u00020\u0002H\u0097\u0001J2\u0010\u0018\u001a\u00020\u00022'\u0010\u0019\u001a#\u0012\u0015\u0012\u0013\u0018\u00010\u0014¢\u0006\f\b\u001b\u0012\b\b\u001c\u0012\u0004\b\b(\u0013\u0012\u0004\u0012\u00020\u00020\u001aj\u0002`\u001dH\u0096\u0001J\u001d\u0010\u0018\u001a\u00020\u00022\n\u0010\u001e\u001a\u0006\u0012\u0002\b\u00030\u001f2\u0006\u0010 \u001a\u00020!H\u0096\u0001J:\u0010\"\u001a\u00020\u00022\u0006\u0010#\u001a\u00020\u00022#\u0010$\u001a\u001f\u0012\u0013\u0012\u00110\u0014¢\u0006\f\b\u001b\u0012\b\b\u001c\u0012\u0004\b\b(\u0013\u0012\u0004\u0012\u00020\u0002\u0018\u00010\u001aH\u0016¢\u0006\u0002\u0010%J\u001f\u0010&\u001a\u00020\u00022\f\u0010'\u001a\b\u0012\u0004\u0012\u00020\u00020(H\u0096\u0001ø\u0001\u0000¢\u0006\u0002\u0010)J$\u0010*\u001a\u0004\u0018\u00010\u00072\u0006\u0010#\u001a\u00020\u00022\n\b\u0002\u0010+\u001a\u0004\u0018\u00010\u0007H\u0097\u0001¢\u0006\u0002\u0010,JF\u0010*\u001a\u0004\u0018\u00010\u00072\u0006\u0010#\u001a\u00020\u00022\b\u0010+\u001a\u0004\u0018\u00010\u00072#\u0010$\u001a\u001f\u0012\u0013\u0012\u00110\u0014¢\u0006\f\b\u001b\u0012\b\b\u001c\u0012\u0004\b\b(\u0013\u0012\u0004\u0012\u00020\u0002\u0018\u00010\u001aH\u0016¢\u0006\u0002\u0010-J\u0013\u0010.\u001a\u0004\u0018\u00010\u00072\u0006\u0010/\u001a\u00020\u0014H\u0097\u0001J\u001a\u00100\u001a\u00020\u0002*\u0002012\u0006\u0010#\u001a\u00020\u0002H\u0097\u0001¢\u0006\u0002\u00102J\u0015\u00103\u001a\u00020\u0002*\u0002012\u0006\u0010/\u001a\u00020\u0014H\u0097\u0001R\u0016\u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00020\u00058\u0006X\u0087\u0004¢\u0006\u0002\n\u0000R\u0012\u0010\t\u001a\u00020\nX\u0096\u0005¢\u0006\u0006\u001a\u0004\b\u000b\u0010\fR\u0012\u0010\r\u001a\u00020\u000eX\u0096\u0005¢\u0006\u0006\u001a\u0004\b\r\u0010\u000fR\u0012\u0010\u0010\u001a\u00020\u000eX\u0096\u0005¢\u0006\u0006\u001a\u0004\b\u0010\u0010\u000fR\u0012\u0010\u0011\u001a\u00020\u000eX\u0096\u0005¢\u0006\u0006\u001a\u0004\b\u0011\u0010\u000fR\u0012\u0010\u0006\u001a\u0004\u0018\u00010\u00078\u0006X\u0087\u0004¢\u0006\u0002\n\u0000\u0082\u0002\u0004\n\u0002\b\u0019¨\u00064"}, d2 = {"Lkotlinx/coroutines/sync/MutexImpl$CancellableContinuationWithOwner;", "Lkotlinx/coroutines/CancellableContinuation;", "", "Lkotlinx/coroutines/Waiter;", "cont", "Lkotlinx/coroutines/CancellableContinuationImpl;", "owner", "", "(Lkotlinx/coroutines/sync/MutexImpl;Lkotlinx/coroutines/CancellableContinuationImpl;Ljava/lang/Object;)V", "context", "Lkotlin/coroutines/CoroutineContext;", "getContext", "()Lkotlin/coroutines/CoroutineContext;", "isActive", "", "()Z", "isCancelled", "isCompleted", "cancel", "cause", "", "completeResume", "token", "initCancellability", "invokeOnCancellation", "handler", "Lkotlin/Function1;", "Lkotlin/ParameterName;", "name", "Lkotlinx/coroutines/CompletionHandler;", "segment", "Lkotlinx/coroutines/internal/Segment;", "index", "", "resume", "value", "onCancellation", "(Lkotlin/Unit;Lkotlin/jvm/functions/Function1;)V", "resumeWith", "result", "Lkotlin/Result;", "(Ljava/lang/Object;)V", "tryResume", "idempotent", "(Lkotlin/Unit;Ljava/lang/Object;)Ljava/lang/Object;", "(Lkotlin/Unit;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;", "tryResumeWithException", "exception", "resumeUndispatched", "Lkotlinx/coroutines/CoroutineDispatcher;", "(Lkotlinx/coroutines/CoroutineDispatcher;Lkotlin/Unit;)V", "resumeUndispatchedWithException", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
private final class CancellableContinuationWithOwner implements CancellableContinuation<Unit>, Waiter {
public final CancellableContinuationImpl<Unit> cont;
public final Object owner;
@Override // kotlinx.coroutines.CancellableContinuation
public boolean cancel(Throwable cause) {
return this.cont.cancel(cause);
}
@Override // kotlinx.coroutines.CancellableContinuation
public void completeResume(Object token) {
this.cont.completeResume(token);
}
@Override // kotlin.coroutines.Continuation
/* renamed from: getContext */
public CoroutineContext get$context() {
return this.cont.get$context();
}
@Override // kotlinx.coroutines.CancellableContinuation
public void initCancellability() {
this.cont.initCancellability();
}
@Override // kotlinx.coroutines.CancellableContinuation
public void invokeOnCancellation(Function1<? super Throwable, Unit> handler) {
this.cont.invokeOnCancellation(handler);
}
@Override // kotlinx.coroutines.Waiter
public void invokeOnCancellation(Segment<?> segment, int index) {
this.cont.invokeOnCancellation(segment, index);
}
@Override // kotlinx.coroutines.CancellableContinuation
public boolean isActive() {
return this.cont.isActive();
}
@Override // kotlinx.coroutines.CancellableContinuation
public boolean isCancelled() {
return this.cont.isCancelled();
}
@Override // kotlinx.coroutines.CancellableContinuation
public boolean isCompleted() {
return this.cont.isCompleted();
}
@Override // kotlinx.coroutines.CancellableContinuation
public void resumeUndispatched(CoroutineDispatcher coroutineDispatcher, Unit unit) {
this.cont.resumeUndispatched(coroutineDispatcher, unit);
}
@Override // kotlinx.coroutines.CancellableContinuation
public void resumeUndispatchedWithException(CoroutineDispatcher coroutineDispatcher, Throwable th) {
this.cont.resumeUndispatchedWithException(coroutineDispatcher, th);
}
@Override // kotlin.coroutines.Continuation
public void resumeWith(Object result) {
this.cont.resumeWith(result);
}
@Override // kotlinx.coroutines.CancellableContinuation
public Object tryResume(Unit value, Object idempotent) {
return this.cont.tryResume(value, idempotent);
}
@Override // kotlinx.coroutines.CancellableContinuation
public Object tryResumeWithException(Throwable exception) {
return this.cont.tryResumeWithException(exception);
}
/* JADX WARN: Multi-variable type inference failed */
public CancellableContinuationWithOwner(CancellableContinuationImpl<? super Unit> cancellableContinuationImpl, Object obj) {
this.cont = cancellableContinuationImpl;
this.owner = obj;
}
@Override // kotlinx.coroutines.CancellableContinuation
public /* bridge */ /* synthetic */ void resume(Unit unit, Function1 function1) {
resume2(unit, (Function1<? super Throwable, Unit>) function1);
}
@Override // kotlinx.coroutines.CancellableContinuation
public /* bridge */ /* synthetic */ Object tryResume(Unit unit, Object obj, Function1 function1) {
return tryResume2(unit, obj, (Function1<? super Throwable, Unit>) function1);
}
/* renamed from: tryResume, reason: avoid collision after fix types in other method */
public Object tryResume2(Unit value, Object idempotent, Function1<? super Throwable, Unit> onCancellation) {
Symbol symbol;
Symbol symbol2;
MutexImpl mutexImpl = MutexImpl.this;
if (DebugKt.getASSERTIONS_ENABLED()) {
Object obj = MutexImpl.owner$FU.get(mutexImpl);
symbol2 = MutexKt.NO_OWNER;
if (obj != symbol2) {
throw new AssertionError();
}
}
CancellableContinuationImpl<Unit> cancellableContinuationImpl = this.cont;
final MutexImpl mutexImpl2 = MutexImpl.this;
Object tryResume = cancellableContinuationImpl.tryResume(value, idempotent, new Function1<Throwable, Unit>() { // from class: kotlinx.coroutines.sync.MutexImpl$CancellableContinuationWithOwner$tryResume$token$1
/* 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 */ Unit invoke(Throwable th) {
invoke2(th);
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2(Throwable th) {
Symbol symbol3;
MutexImpl mutexImpl3 = MutexImpl.this;
MutexImpl.CancellableContinuationWithOwner cancellableContinuationWithOwner = this;
if (DebugKt.getASSERTIONS_ENABLED()) {
Object obj2 = MutexImpl.owner$FU.get(mutexImpl3);
symbol3 = MutexKt.NO_OWNER;
if (obj2 != symbol3 && obj2 != cancellableContinuationWithOwner.owner) {
throw new AssertionError();
}
}
MutexImpl.owner$FU.set(MutexImpl.this, this.owner);
MutexImpl.this.unlock(this.owner);
}
});
if (tryResume != null) {
MutexImpl mutexImpl3 = MutexImpl.this;
if (DebugKt.getASSERTIONS_ENABLED()) {
Object obj2 = MutexImpl.owner$FU.get(mutexImpl3);
symbol = MutexKt.NO_OWNER;
if (obj2 != symbol) {
throw new AssertionError();
}
}
MutexImpl.owner$FU.set(MutexImpl.this, this.owner);
}
return tryResume;
}
/* renamed from: resume, reason: avoid collision after fix types in other method */
public void resume2(Unit value, Function1<? super Throwable, Unit> onCancellation) {
Symbol symbol;
MutexImpl mutexImpl = MutexImpl.this;
if (DebugKt.getASSERTIONS_ENABLED()) {
Object obj = MutexImpl.owner$FU.get(mutexImpl);
symbol = MutexKt.NO_OWNER;
if (obj != symbol) {
throw new AssertionError();
}
}
MutexImpl.owner$FU.set(MutexImpl.this, this.owner);
CancellableContinuationImpl<Unit> cancellableContinuationImpl = this.cont;
final MutexImpl mutexImpl2 = MutexImpl.this;
cancellableContinuationImpl.resume(value, new Function1<Throwable, Unit>() { // from class: kotlinx.coroutines.sync.MutexImpl$CancellableContinuationWithOwner$resume$2
/* 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 */ Unit invoke(Throwable th) {
invoke2(th);
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2(Throwable th) {
MutexImpl.this.unlock(this.owner);
}
});
}
}
/* compiled from: Mutex.kt */
@Metadata(d1 = {"\u0000B\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0003\b\u0082\u0004\u0018\u0000*\u0004\b\u0000\u0010\u00012\b\u0012\u0004\u0012\u0002H\u00010\u0002B\u001d\u0012\f\u0010\u0003\u001a\b\u0012\u0004\u0012\u00028\u00000\u0002\u0012\b\u0010\u0004\u001a\u0004\u0018\u00010\u0005¢\u0006\u0002\u0010\u0006J\u0011\u0010\u000b\u001a\u00020\f2\u0006\u0010\r\u001a\u00020\u000eH\u0096\u0001J\u001d\u0010\u000f\u001a\u00020\f2\n\u0010\u0010\u001a\u0006\u0012\u0002\b\u00030\u00112\u0006\u0010\u0012\u001a\u00020\u0013H\u0096\u0001J\u0012\u0010\u0014\u001a\u00020\f2\b\u0010\u0015\u001a\u0004\u0018\u00010\u0005H\u0016J\u001a\u0010\u0016\u001a\u00020\u00172\u0006\u0010\u0018\u001a\u00020\u00052\b\u0010\u0019\u001a\u0004\u0018\u00010\u0005H\u0016R\u0012\u0010\u0007\u001a\u00020\bX\u0096\u0005¢\u0006\u0006\u001a\u0004\b\t\u0010\nR\u0012\u0010\u0004\u001a\u0004\u0018\u00010\u00058\u0006X\u0087\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\u0003\u001a\b\u0012\u0004\u0012\u00028\u00000\u00028\u0006X\u0087\u0004¢\u0006\u0002\n\u0000¨\u0006\u001a"}, d2 = {"Lkotlinx/coroutines/sync/MutexImpl$SelectInstanceWithOwner;", "Q", "Lkotlinx/coroutines/selects/SelectInstanceInternal;", "select", "owner", "", "(Lkotlinx/coroutines/sync/MutexImpl;Lkotlinx/coroutines/selects/SelectInstanceInternal;Ljava/lang/Object;)V", "context", "Lkotlin/coroutines/CoroutineContext;", "getContext", "()Lkotlin/coroutines/CoroutineContext;", "disposeOnCompletion", "", "disposableHandle", "Lkotlinx/coroutines/DisposableHandle;", "invokeOnCancellation", "segment", "Lkotlinx/coroutines/internal/Segment;", "index", "", "selectInRegistrationPhase", "internalResult", "trySelect", "", "clauseObject", "result", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
private final class SelectInstanceWithOwner<Q> implements SelectInstanceInternal<Q> {
public final Object owner;
public final SelectInstanceInternal<Q> select;
@Override // kotlinx.coroutines.selects.SelectInstance
public void disposeOnCompletion(DisposableHandle disposableHandle) {
this.select.disposeOnCompletion(disposableHandle);
}
@Override // kotlinx.coroutines.selects.SelectInstance
public CoroutineContext getContext() {
return this.select.getContext();
}
@Override // kotlinx.coroutines.Waiter
public void invokeOnCancellation(Segment<?> segment, int index) {
this.select.invokeOnCancellation(segment, index);
}
public SelectInstanceWithOwner(SelectInstanceInternal<Q> selectInstanceInternal, Object obj) {
this.select = selectInstanceInternal;
this.owner = obj;
}
@Override // kotlinx.coroutines.selects.SelectInstance
public boolean trySelect(Object clauseObject, Object result) {
Symbol symbol;
MutexImpl mutexImpl = MutexImpl.this;
if (DebugKt.getASSERTIONS_ENABLED()) {
Object obj = MutexImpl.owner$FU.get(mutexImpl);
symbol = MutexKt.NO_OWNER;
if (obj != symbol) {
throw new AssertionError();
}
}
boolean trySelect = this.select.trySelect(clauseObject, result);
MutexImpl mutexImpl2 = MutexImpl.this;
if (trySelect) {
MutexImpl.owner$FU.set(mutexImpl2, this.owner);
}
return trySelect;
}
@Override // kotlinx.coroutines.selects.SelectInstance
public void selectInRegistrationPhase(Object internalResult) {
Symbol symbol;
MutexImpl mutexImpl = MutexImpl.this;
if (DebugKt.getASSERTIONS_ENABLED()) {
Object obj = MutexImpl.owner$FU.get(mutexImpl);
symbol = MutexKt.NO_OWNER;
if (obj != symbol) {
throw new AssertionError();
}
}
MutexImpl.owner$FU.set(MutexImpl.this, this.owner);
this.select.selectInRegistrationPhase(internalResult);
}
}
public String toString() {
return "Mutex@" + DebugStringsKt.getHexAddress(this) + "[isLocked=" + isLocked() + ",owner=" + owner$FU.get(this) + ']';
}
/* JADX INFO: Access modifiers changed from: private */
public final Object lockSuspend(Object obj, Continuation<? super Unit> continuation) {
CancellableContinuationImpl orCreateCancellableContinuation = CancellableContinuationKt.getOrCreateCancellableContinuation(IntrinsicsKt.intercepted(continuation));
try {
acquire((CancellableContinuation<? super Unit>) new CancellableContinuationWithOwner(orCreateCancellableContinuation, obj));
Object result = orCreateCancellableContinuation.getResult();
if (result == IntrinsicsKt.getCOROUTINE_SUSPENDED()) {
DebugProbesKt.probeCoroutineSuspended(continuation);
}
return result == IntrinsicsKt.getCOROUTINE_SUSPENDED() ? result : Unit.INSTANCE;
} catch (Throwable th) {
orCreateCancellableContinuation.releaseClaimedReusableContinuation$kotlinx_coroutines_core();
throw th;
}
}
}

View File

@ -0,0 +1,29 @@
package kotlinx.coroutines.sync;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;
/* compiled from: Mutex.kt */
@Metadata(k = 3, mv = {1, 8, 0}, xi = 176)
@DebugMetadata(c = "kotlinx.coroutines.sync.MutexKt", f = "Mutex.kt", i = {0, 0, 0}, l = {125}, m = "withLock", n = {"$this$withLock", "owner", "action"}, s = {"L$0", "L$1", "L$2"})
/* loaded from: classes.dex */
final class MutexKt$withLock$1<T> extends ContinuationImpl {
Object L$0;
Object L$1;
Object L$2;
int label;
/* synthetic */ Object result;
MutexKt$withLock$1(Continuation<? super MutexKt$withLock$1> continuation) {
super(continuation);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
this.result = obj;
this.label |= Integer.MIN_VALUE;
return MutexKt.withLock(null, null, null, this);
}
}

View File

@ -0,0 +1,126 @@
package kotlinx.coroutines.sync;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.InlineMarker;
import kotlinx.coroutines.internal.Symbol;
/* compiled from: Mutex.kt */
@Metadata(d1 = {"\u0000.\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u001a\u0010\u0010\u0007\u001a\u00020\b2\b\b\u0002\u0010\t\u001a\u00020\n\u001aB\u0010\u000b\u001a\u0002H\f\"\u0004\b\u0000\u0010\f*\u00020\b2\n\b\u0002\u0010\r\u001a\u0004\u0018\u00010\u000e2\f\u0010\u000f\u001a\b\u0012\u0004\u0012\u0002H\f0\u0010H\u0086Hø\u0001\u0000\u0082\u0002\n\n\b\b\u0001\u0012\u0002\u0010\u0002 \u0001¢\u0006\u0002\u0010\u0011\"\u000e\u0010\u0000\u001a\u00020\u0001X\u0082\u0004¢\u0006\u0002\n\u0000\"\u000e\u0010\u0002\u001a\u00020\u0001X\u0082\u0004¢\u0006\u0002\n\u0000\"\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000\"\u000e\u0010\u0005\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000\"\u000e\u0010\u0006\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\u0012"}, d2 = {"NO_OWNER", "Lkotlinx/coroutines/internal/Symbol;", "ON_LOCK_ALREADY_LOCKED_BY_OWNER", "TRY_LOCK_ALREADY_LOCKED_BY_OWNER", "", "TRY_LOCK_FAILED", "TRY_LOCK_SUCCESS", "Mutex", "Lkotlinx/coroutines/sync/Mutex;", "locked", "", "withLock", "T", "owner", "", "action", "Lkotlin/Function0;", "(Lkotlinx/coroutines/sync/Mutex;Ljava/lang/Object;Lkotlin/jvm/functions/Function0;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "kotlinx-coroutines-core"}, k = 2, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public final class MutexKt {
private static final Symbol NO_OWNER = new Symbol("NO_OWNER");
private static final Symbol ON_LOCK_ALREADY_LOCKED_BY_OWNER = new Symbol("ALREADY_LOCKED_BY_OWNER");
private static final int TRY_LOCK_ALREADY_LOCKED_BY_OWNER = 2;
private static final int TRY_LOCK_FAILED = 1;
private static final int TRY_LOCK_SUCCESS = 0;
public static /* synthetic */ Mutex Mutex$default(boolean z, int i, Object obj) {
if ((i & 1) != 0) {
z = false;
}
return Mutex(z);
}
public static final Mutex Mutex(boolean z) {
return new MutexImpl(z);
}
/* JADX WARN: Removed duplicated region for block: B:21:0x003d */
/* JADX WARN: Removed duplicated region for block: B:8:0x0024 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static final <T> java.lang.Object withLock(kotlinx.coroutines.sync.Mutex r4, java.lang.Object r5, kotlin.jvm.functions.Function0<? extends T> r6, kotlin.coroutines.Continuation<? super T> r7) {
/*
boolean r0 = r7 instanceof kotlinx.coroutines.sync.MutexKt$withLock$1
if (r0 == 0) goto L14
r0 = r7
kotlinx.coroutines.sync.MutexKt$withLock$1 r0 = (kotlinx.coroutines.sync.MutexKt$withLock$1) r0
int r1 = r0.label
r2 = -2147483648(0xffffffff80000000, float:-0.0)
r1 = r1 & r2
if (r1 == 0) goto L14
int r7 = r0.label
int r7 = r7 - r2
r0.label = r7
goto L19
L14:
kotlinx.coroutines.sync.MutexKt$withLock$1 r0 = new kotlinx.coroutines.sync.MutexKt$withLock$1
r0.<init>(r7)
L19:
java.lang.Object r7 = r0.result
java.lang.Object r1 = kotlin.coroutines.intrinsics.IntrinsicsKt.getCOROUTINE_SUSPENDED()
int r2 = r0.label
r3 = 1
if (r2 == 0) goto L3d
if (r2 != r3) goto L35
java.lang.Object r4 = r0.L$2
r6 = r4
kotlin.jvm.functions.Function0 r6 = (kotlin.jvm.functions.Function0) r6
java.lang.Object r5 = r0.L$1
java.lang.Object r4 = r0.L$0
kotlinx.coroutines.sync.Mutex r4 = (kotlinx.coroutines.sync.Mutex) r4
kotlin.ResultKt.throwOnFailure(r7)
goto L4f
L35:
java.lang.IllegalStateException r4 = new java.lang.IllegalStateException
java.lang.String r5 = "call to 'resume' before 'invoke' with coroutine"
r4.<init>(r5)
throw r4
L3d:
kotlin.ResultKt.throwOnFailure(r7)
r0.L$0 = r4
r0.L$1 = r5
r0.L$2 = r6
r0.label = r3
java.lang.Object r7 = r4.lock(r5, r0)
if (r7 != r1) goto L4f
return r1
L4f:
java.lang.Object r6 = r6.invoke() // Catch: java.lang.Throwable -> L5d
kotlin.jvm.internal.InlineMarker.finallyStart(r3)
r4.unlock(r5)
kotlin.jvm.internal.InlineMarker.finallyEnd(r3)
return r6
L5d:
r6 = move-exception
kotlin.jvm.internal.InlineMarker.finallyStart(r3)
r4.unlock(r5)
kotlin.jvm.internal.InlineMarker.finallyEnd(r3)
throw r6
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.sync.MutexKt.withLock(kotlinx.coroutines.sync.Mutex, java.lang.Object, kotlin.jvm.functions.Function0, kotlin.coroutines.Continuation):java.lang.Object");
}
private static final <T> Object withLock$$forInline(Mutex mutex, Object obj, Function0<? extends T> function0, Continuation<? super T> continuation) {
InlineMarker.mark(0);
mutex.lock(obj, continuation);
InlineMarker.mark(1);
try {
return function0.invoke();
} finally {
InlineMarker.finallyStart(1);
mutex.unlock(obj);
InlineMarker.finallyEnd(1);
}
}
public static /* synthetic */ Object withLock$default(Mutex mutex, Object obj, Function0 function0, Continuation continuation, int i, Object obj2) {
if ((i & 1) != 0) {
obj = null;
}
InlineMarker.mark(0);
mutex.lock(obj, continuation);
InlineMarker.mark(1);
try {
return function0.invoke();
} finally {
InlineMarker.finallyStart(1);
mutex.unlock(obj);
InlineMarker.finallyEnd(1);
}
}
}

View File

@ -0,0 +1,18 @@
package kotlinx.coroutines.sync;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
/* compiled from: Semaphore.kt */
@Metadata(d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0000\bf\u0018\u00002\u00020\u0001J\u0011\u0010\u0006\u001a\u00020\u0007H¦@ø\u0001\u0000¢\u0006\u0002\u0010\bJ\b\u0010\t\u001a\u00020\u0007H&J\b\u0010\n\u001a\u00020\u000bH&R\u0012\u0010\u0002\u001a\u00020\u0003X¦\u0004¢\u0006\u0006\u001a\u0004\b\u0004\u0010\u0005\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\f"}, d2 = {"Lkotlinx/coroutines/sync/Semaphore;", "", "availablePermits", "", "getAvailablePermits", "()I", "acquire", "", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "release", "tryAcquire", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public interface Semaphore {
Object acquire(Continuation<? super Unit> continuation);
int getAvailablePermits();
void release();
boolean tryAcquire();
}

View File

@ -0,0 +1,27 @@
package kotlinx.coroutines.sync;
import kotlin.Metadata;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.FunctionReferenceImpl;
/* compiled from: Semaphore.kt */
@Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
/* synthetic */ class SemaphoreImpl$addAcquireToQueue$createNewSegment$1 extends FunctionReferenceImpl implements Function2<Long, SemaphoreSegment, SemaphoreSegment> {
public static final SemaphoreImpl$addAcquireToQueue$createNewSegment$1 INSTANCE = new SemaphoreImpl$addAcquireToQueue$createNewSegment$1();
SemaphoreImpl$addAcquireToQueue$createNewSegment$1() {
super(2, SemaphoreKt.class, "createSegment", "createSegment(JLkotlinx/coroutines/sync/SemaphoreSegment;)Lkotlinx/coroutines/sync/SemaphoreSegment;", 1);
}
@Override // kotlin.jvm.functions.Function2
public /* bridge */ /* synthetic */ SemaphoreSegment invoke(Long l, SemaphoreSegment semaphoreSegment) {
return invoke(l.longValue(), semaphoreSegment);
}
public final SemaphoreSegment invoke(long j, SemaphoreSegment semaphoreSegment) {
SemaphoreSegment createSegment;
createSegment = SemaphoreKt.createSegment(j, semaphoreSegment);
return createSegment;
}
}

View File

@ -0,0 +1,27 @@
package kotlinx.coroutines.sync;
import kotlin.Metadata;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.FunctionReferenceImpl;
/* compiled from: Semaphore.kt */
@Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
/* synthetic */ class SemaphoreImpl$tryResumeNextFromQueue$createNewSegment$1 extends FunctionReferenceImpl implements Function2<Long, SemaphoreSegment, SemaphoreSegment> {
public static final SemaphoreImpl$tryResumeNextFromQueue$createNewSegment$1 INSTANCE = new SemaphoreImpl$tryResumeNextFromQueue$createNewSegment$1();
SemaphoreImpl$tryResumeNextFromQueue$createNewSegment$1() {
super(2, SemaphoreKt.class, "createSegment", "createSegment(JLkotlinx/coroutines/sync/SemaphoreSegment;)Lkotlinx/coroutines/sync/SemaphoreSegment;", 1);
}
@Override // kotlin.jvm.functions.Function2
public /* bridge */ /* synthetic */ SemaphoreSegment invoke(Long l, SemaphoreSegment semaphoreSegment) {
return invoke(l.longValue(), semaphoreSegment);
}
public final SemaphoreSegment invoke(long j, SemaphoreSegment semaphoreSegment) {
SemaphoreSegment createSegment;
createSegment = SemaphoreKt.createSegment(j, semaphoreSegment);
return createSegment;
}
}

View File

@ -0,0 +1,356 @@
package kotlinx.coroutines.sync;
import androidx.concurrent.futures.AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugProbesKt;
import kotlin.jvm.Volatile;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.CancellableContinuation;
import kotlinx.coroutines.CancellableContinuationImpl;
import kotlinx.coroutines.CancellableContinuationKt;
import kotlinx.coroutines.DebugKt;
import kotlinx.coroutines.Waiter;
import kotlinx.coroutines.channels.ChannelSegment$$ExternalSyntheticBackportWithForwarding0;
import kotlinx.coroutines.internal.ConcurrentLinkedListKt;
import kotlinx.coroutines.internal.Segment;
import kotlinx.coroutines.internal.SegmentOrClosed;
import kotlinx.coroutines.internal.Symbol;
import kotlinx.coroutines.selects.SelectInstance;
/* compiled from: Semaphore.kt */
@Metadata(d1 = {"\u0000h\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u0003\n\u0002\u0010\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0000\n\u0002\b\u0005\b\u0010\u0018\u00002\u00020\u0001B\u0015\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0003¢\u0006\u0002\u0010\u0005J\u0011\u0010\u0016\u001a\u00020\u0014H\u0096@ø\u0001\u0000¢\u0006\u0002\u0010\u0017Jb\u0010\u0016\u001a\u00020\u0014\"\u0004\b\u0000\u0010\u00182\u0006\u0010\u0019\u001a\u0002H\u00182!\u0010\u001a\u001a\u001d\u0012\u0013\u0012\u0011H\u0018¢\u0006\f\b\u001b\u0012\b\b\u001c\u0012\u0004\b\b(\u0019\u0012\u0004\u0012\u00020\u001d0\u00122!\u0010\u001e\u001a\u001d\u0012\u0013\u0012\u0011H\u0018¢\u0006\f\b\u001b\u0012\b\b\u001c\u0012\u0004\b\b(\u0019\u0012\u0004\u0012\u00020\u00140\u0012H\u0083\\u0006\u0002\u0010\u001fJ\u0016\u0010\u0016\u001a\u00020\u00142\f\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\u00140 H\u0005J\u0011\u0010!\u001a\u00020\u0014H\u0082@ø\u0001\u0000¢\u0006\u0002\u0010\u0017J\u0010\u0010\"\u001a\u00020\u001d2\u0006\u0010\u0019\u001a\u00020#H\u0002J\b\u0010$\u001a\u00020\u0014H\u0002J\b\u0010%\u001a\u00020\u0003H\u0002J\u001e\u0010&\u001a\u00020\u00142\n\u0010'\u001a\u0006\u0012\u0002\b\u00030(2\b\u0010)\u001a\u0004\u0018\u00010*H\u0004J\b\u0010+\u001a\u00020\u0014H\u0016J\b\u0010,\u001a\u00020\u001dH\u0016J\b\u0010-\u001a\u00020\u001dH\u0002J\f\u0010.\u001a\u00020\u001d*\u00020*H\u0002R\t\u0010\u0006\u001a\u00020\u0007X\u0082\u0004R\u0014\u0010\b\u001a\u00020\u00038VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\t\u0010\nR\t\u0010\u000b\u001a\u00020\fX\u0082\u0004R\t\u0010\r\u001a\u00020\fX\u0082\u0004R\u000f\u0010\u000e\u001a\b\u0012\u0004\u0012\u00020\u00100\u000fX\u0082\u0004R\u001a\u0010\u0011\u001a\u000e\u0012\u0004\u0012\u00020\u0013\u0012\u0004\u0012\u00020\u00140\u0012X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000f\u0010\u0015\u001a\b\u0012\u0004\u0012\u00020\u00100\u000fX\u0082\u0004\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006/"}, d2 = {"Lkotlinx/coroutines/sync/SemaphoreImpl;", "Lkotlinx/coroutines/sync/Semaphore;", "permits", "", "acquiredPermits", "(II)V", "_availablePermits", "Lkotlinx/atomicfu/AtomicInt;", "availablePermits", "getAvailablePermits", "()I", "deqIdx", "Lkotlinx/atomicfu/AtomicLong;", "enqIdx", "head", "Lkotlinx/atomicfu/AtomicRef;", "Lkotlinx/coroutines/sync/SemaphoreSegment;", "onCancellationRelease", "Lkotlin/Function1;", "", "", "tail", "acquire", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "W", "waiter", "suspend", "Lkotlin/ParameterName;", "name", "", "onAcquired", "(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V", "Lkotlinx/coroutines/CancellableContinuation;", "acquireSlowPath", "addAcquireToQueue", "Lkotlinx/coroutines/Waiter;", "coerceAvailablePermitsAtMaximum", "decPermits", "onAcquireRegFunction", "select", "Lkotlinx/coroutines/selects/SelectInstance;", "ignoredParam", "", "release", "tryAcquire", "tryResumeNextFromQueue", "tryResumeAcquire", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public class SemaphoreImpl implements Semaphore {
@Volatile
private volatile int _availablePermits;
@Volatile
private volatile long deqIdx;
@Volatile
private volatile long enqIdx;
@Volatile
private volatile Object head;
private final Function1<Throwable, Unit> onCancellationRelease;
private final int permits;
@Volatile
private volatile Object tail;
private static final AtomicReferenceFieldUpdater head$FU = AtomicReferenceFieldUpdater.newUpdater(SemaphoreImpl.class, Object.class, "head");
private static final AtomicLongFieldUpdater deqIdx$FU = AtomicLongFieldUpdater.newUpdater(SemaphoreImpl.class, "deqIdx");
private static final AtomicReferenceFieldUpdater tail$FU = AtomicReferenceFieldUpdater.newUpdater(SemaphoreImpl.class, Object.class, "tail");
private static final AtomicLongFieldUpdater enqIdx$FU = AtomicLongFieldUpdater.newUpdater(SemaphoreImpl.class, "enqIdx");
private static final AtomicIntegerFieldUpdater _availablePermits$FU = AtomicIntegerFieldUpdater.newUpdater(SemaphoreImpl.class, "_availablePermits");
@Override // kotlinx.coroutines.sync.Semaphore
public Object acquire(Continuation<? super Unit> continuation) {
return acquire$suspendImpl(this, continuation);
}
public SemaphoreImpl(int i, int i2) {
this.permits = i;
if (i <= 0) {
throw new IllegalArgumentException(("Semaphore should have at least 1 permit, but had " + i).toString());
}
if (i2 < 0 || i2 > i) {
throw new IllegalArgumentException(("The number of acquired permits should be in 0.." + i).toString());
}
SemaphoreSegment semaphoreSegment = new SemaphoreSegment(0L, null, 2);
this.head = semaphoreSegment;
this.tail = semaphoreSegment;
this._availablePermits = i - i2;
this.onCancellationRelease = new Function1<Throwable, Unit>() { // from class: kotlinx.coroutines.sync.SemaphoreImpl$onCancellationRelease$1
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(Throwable th) {
invoke2(th);
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2(Throwable th) {
SemaphoreImpl.this.release();
}
};
}
@Override // kotlinx.coroutines.sync.Semaphore
public int getAvailablePermits() {
return Math.max(_availablePermits$FU.get(this), 0);
}
@Override // kotlinx.coroutines.sync.Semaphore
public boolean tryAcquire() {
while (true) {
AtomicIntegerFieldUpdater atomicIntegerFieldUpdater = _availablePermits$FU;
int i = atomicIntegerFieldUpdater.get(this);
if (i > this.permits) {
coerceAvailablePermitsAtMaximum();
} else {
if (i <= 0) {
return false;
}
if (atomicIntegerFieldUpdater.compareAndSet(this, i, i - 1)) {
return true;
}
}
}
}
static /* synthetic */ Object acquire$suspendImpl(SemaphoreImpl semaphoreImpl, Continuation<? super Unit> continuation) {
if (semaphoreImpl.decPermits() > 0) {
return Unit.INSTANCE;
}
Object acquireSlowPath = semaphoreImpl.acquireSlowPath(continuation);
return acquireSlowPath == IntrinsicsKt.getCOROUTINE_SUSPENDED() ? acquireSlowPath : Unit.INSTANCE;
}
private final <W> void acquire(W waiter, Function1<? super W, Boolean> suspend, Function1<? super W, Unit> onAcquired) {
while (decPermits() <= 0) {
if (suspend.invoke(waiter).booleanValue()) {
return;
}
}
onAcquired.invoke(waiter);
}
private final int decPermits() {
int andDecrement;
do {
andDecrement = _availablePermits$FU.getAndDecrement(this);
} while (andDecrement > this.permits);
return andDecrement;
}
@Override // kotlinx.coroutines.sync.Semaphore
public void release() {
do {
int andIncrement = _availablePermits$FU.getAndIncrement(this);
if (andIncrement >= this.permits) {
coerceAvailablePermitsAtMaximum();
throw new IllegalStateException(("The number of released permits cannot be greater than " + this.permits).toString());
}
if (andIncrement >= 0) {
return;
}
} while (!tryResumeNextFromQueue());
}
private final void coerceAvailablePermitsAtMaximum() {
AtomicIntegerFieldUpdater atomicIntegerFieldUpdater;
int i;
int i2;
do {
atomicIntegerFieldUpdater = _availablePermits$FU;
i = atomicIntegerFieldUpdater.get(this);
i2 = this.permits;
if (i <= i2) {
return;
}
} while (!atomicIntegerFieldUpdater.compareAndSet(this, i, i2));
}
/* JADX INFO: Access modifiers changed from: private */
public final boolean addAcquireToQueue(Waiter waiter) {
int i;
Object findSegmentInternal;
int i2;
Symbol symbol;
Symbol symbol2;
Symbol symbol3;
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = tail$FU;
SemaphoreSegment semaphoreSegment = (SemaphoreSegment) atomicReferenceFieldUpdater.get(this);
long andIncrement = enqIdx$FU.getAndIncrement(this);
SemaphoreImpl$addAcquireToQueue$createNewSegment$1 semaphoreImpl$addAcquireToQueue$createNewSegment$1 = SemaphoreImpl$addAcquireToQueue$createNewSegment$1.INSTANCE;
i = SemaphoreKt.SEGMENT_SIZE;
long j = andIncrement / i;
loop0: while (true) {
findSegmentInternal = ConcurrentLinkedListKt.findSegmentInternal(semaphoreSegment, j, semaphoreImpl$addAcquireToQueue$createNewSegment$1);
if (!SegmentOrClosed.m1915isClosedimpl(findSegmentInternal)) {
Segment m1913getSegmentimpl = SegmentOrClosed.m1913getSegmentimpl(findSegmentInternal);
while (true) {
Segment segment = (Segment) atomicReferenceFieldUpdater.get(this);
if (segment.id >= m1913getSegmentimpl.id) {
break loop0;
}
if (!m1913getSegmentimpl.tryIncPointers$kotlinx_coroutines_core()) {
break;
}
if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, segment, m1913getSegmentimpl)) {
if (segment.decPointers$kotlinx_coroutines_core()) {
segment.remove();
}
} else if (m1913getSegmentimpl.decPointers$kotlinx_coroutines_core()) {
m1913getSegmentimpl.remove();
}
}
} else {
break;
}
}
SemaphoreSegment semaphoreSegment2 = (SemaphoreSegment) SegmentOrClosed.m1913getSegmentimpl(findSegmentInternal);
i2 = SemaphoreKt.SEGMENT_SIZE;
int i3 = (int) (andIncrement % i2);
if (ChannelSegment$$ExternalSyntheticBackportWithForwarding0.m(semaphoreSegment2.getAcquirers(), i3, null, waiter)) {
waiter.invokeOnCancellation(semaphoreSegment2, i3);
return true;
}
symbol = SemaphoreKt.PERMIT;
symbol2 = SemaphoreKt.TAKEN;
if (ChannelSegment$$ExternalSyntheticBackportWithForwarding0.m(semaphoreSegment2.getAcquirers(), i3, symbol, symbol2)) {
if (waiter instanceof CancellableContinuation) {
Intrinsics.checkNotNull(waiter, "null cannot be cast to non-null type kotlinx.coroutines.CancellableContinuation<kotlin.Unit>");
((CancellableContinuation) waiter).resume(Unit.INSTANCE, this.onCancellationRelease);
} else if (waiter instanceof SelectInstance) {
((SelectInstance) waiter).selectInRegistrationPhase(Unit.INSTANCE);
} else {
throw new IllegalStateException(("unexpected: " + waiter).toString());
}
return true;
}
if (!DebugKt.getASSERTIONS_ENABLED()) {
return false;
}
Object obj = semaphoreSegment2.getAcquirers().get(i3);
symbol3 = SemaphoreKt.BROKEN;
if (obj == symbol3) {
return false;
}
throw new AssertionError();
}
private final boolean tryResumeNextFromQueue() {
int i;
Object findSegmentInternal;
int i2;
Symbol symbol;
Symbol symbol2;
int i3;
Symbol symbol3;
Symbol symbol4;
Symbol symbol5;
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = head$FU;
SemaphoreSegment semaphoreSegment = (SemaphoreSegment) atomicReferenceFieldUpdater.get(this);
long andIncrement = deqIdx$FU.getAndIncrement(this);
i = SemaphoreKt.SEGMENT_SIZE;
long j = andIncrement / i;
SemaphoreImpl$tryResumeNextFromQueue$createNewSegment$1 semaphoreImpl$tryResumeNextFromQueue$createNewSegment$1 = SemaphoreImpl$tryResumeNextFromQueue$createNewSegment$1.INSTANCE;
loop0: while (true) {
findSegmentInternal = ConcurrentLinkedListKt.findSegmentInternal(semaphoreSegment, j, semaphoreImpl$tryResumeNextFromQueue$createNewSegment$1);
if (SegmentOrClosed.m1915isClosedimpl(findSegmentInternal)) {
break;
}
Segment m1913getSegmentimpl = SegmentOrClosed.m1913getSegmentimpl(findSegmentInternal);
while (true) {
Segment segment = (Segment) atomicReferenceFieldUpdater.get(this);
if (segment.id >= m1913getSegmentimpl.id) {
break loop0;
}
if (!m1913getSegmentimpl.tryIncPointers$kotlinx_coroutines_core()) {
break;
}
if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, segment, m1913getSegmentimpl)) {
if (segment.decPointers$kotlinx_coroutines_core()) {
segment.remove();
}
} else if (m1913getSegmentimpl.decPointers$kotlinx_coroutines_core()) {
m1913getSegmentimpl.remove();
}
}
}
SemaphoreSegment semaphoreSegment2 = (SemaphoreSegment) SegmentOrClosed.m1913getSegmentimpl(findSegmentInternal);
semaphoreSegment2.cleanPrev();
if (semaphoreSegment2.id > j) {
return false;
}
i2 = SemaphoreKt.SEGMENT_SIZE;
int i4 = (int) (andIncrement % i2);
symbol = SemaphoreKt.PERMIT;
Object andSet = semaphoreSegment2.getAcquirers().getAndSet(i4, symbol);
if (andSet == null) {
i3 = SemaphoreKt.MAX_SPIN_CYCLES;
for (int i5 = 0; i5 < i3; i5++) {
Object obj = semaphoreSegment2.getAcquirers().get(i4);
symbol5 = SemaphoreKt.TAKEN;
if (obj == symbol5) {
return true;
}
}
symbol3 = SemaphoreKt.PERMIT;
symbol4 = SemaphoreKt.BROKEN;
return !ChannelSegment$$ExternalSyntheticBackportWithForwarding0.m(semaphoreSegment2.getAcquirers(), i4, symbol3, symbol4);
}
symbol2 = SemaphoreKt.CANCELLED;
if (andSet == symbol2) {
return false;
}
return tryResumeAcquire(andSet);
}
private final boolean tryResumeAcquire(Object obj) {
if (obj instanceof CancellableContinuation) {
Intrinsics.checkNotNull(obj, "null cannot be cast to non-null type kotlinx.coroutines.CancellableContinuation<kotlin.Unit>");
CancellableContinuation cancellableContinuation = (CancellableContinuation) obj;
Object tryResume = cancellableContinuation.tryResume(Unit.INSTANCE, null, this.onCancellationRelease);
if (tryResume == null) {
return false;
}
cancellableContinuation.completeResume(tryResume);
return true;
}
if (obj instanceof SelectInstance) {
return ((SelectInstance) obj).trySelect(this, Unit.INSTANCE);
}
throw new IllegalStateException(("unexpected: " + obj).toString());
}
/* JADX INFO: Access modifiers changed from: private */
public final Object acquireSlowPath(Continuation<? super Unit> continuation) {
CancellableContinuationImpl orCreateCancellableContinuation = CancellableContinuationKt.getOrCreateCancellableContinuation(IntrinsicsKt.intercepted(continuation));
try {
if (!addAcquireToQueue(orCreateCancellableContinuation)) {
acquire((CancellableContinuation<? super Unit>) orCreateCancellableContinuation);
}
Object result = orCreateCancellableContinuation.getResult();
if (result == IntrinsicsKt.getCOROUTINE_SUSPENDED()) {
DebugProbesKt.probeCoroutineSuspended(continuation);
}
return result == IntrinsicsKt.getCOROUTINE_SUSPENDED() ? result : Unit.INSTANCE;
} catch (Throwable th) {
orCreateCancellableContinuation.releaseClaimedReusableContinuation$kotlinx_coroutines_core();
throw th;
}
}
protected final void acquire(CancellableContinuation<? super Unit> waiter) {
while (decPermits() <= 0) {
Intrinsics.checkNotNull(waiter, "null cannot be cast to non-null type kotlinx.coroutines.Waiter");
if (addAcquireToQueue((Waiter) waiter)) {
return;
}
}
waiter.resume(Unit.INSTANCE, this.onCancellationRelease);
}
protected final void onAcquireRegFunction(SelectInstance<?> select, Object ignoredParam) {
while (decPermits() <= 0) {
Intrinsics.checkNotNull(select, "null cannot be cast to non-null type kotlinx.coroutines.Waiter");
if (addAcquireToQueue((Waiter) select)) {
return;
}
}
select.selectInRegistrationPhase(Unit.INSTANCE);
}
}

View File

@ -0,0 +1,28 @@
package kotlinx.coroutines.sync;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;
/* compiled from: Semaphore.kt */
@Metadata(k = 3, mv = {1, 8, 0}, xi = 176)
@DebugMetadata(c = "kotlinx.coroutines.sync.SemaphoreKt", f = "Semaphore.kt", i = {0, 0}, l = {86}, m = "withPermit", n = {"$this$withPermit", "action"}, s = {"L$0", "L$1"})
/* loaded from: classes.dex */
final class SemaphoreKt$withPermit$1<T> extends ContinuationImpl {
Object L$0;
Object L$1;
int label;
/* synthetic */ Object result;
SemaphoreKt$withPermit$1(Continuation<? super SemaphoreKt$withPermit$1> continuation) {
super(continuation);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
this.result = obj;
this.label |= Integer.MIN_VALUE;
return SemaphoreKt.withPermit(null, null, this);
}
}

View File

@ -0,0 +1,128 @@
package kotlinx.coroutines.sync;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.InlineMarker;
import kotlinx.coroutines.internal.Symbol;
import kotlinx.coroutines.internal.SystemPropsKt__SystemProps_commonKt;
/* compiled from: Semaphore.kt */
@Metadata(d1 = {"\u00000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\u001a\u0018\u0010\b\u001a\u00020\t2\u0006\u0010\n\u001a\u00020\u00042\b\b\u0002\u0010\u000b\u001a\u00020\u0004\u001a\u001a\u0010\f\u001a\u00020\r2\u0006\u0010\u000e\u001a\u00020\u000f2\b\u0010\u0010\u001a\u0004\u0018\u00010\rH\u0002\u001a6\u0010\u0011\u001a\u0002H\u0012\"\u0004\b\u0000\u0010\u0012*\u00020\t2\f\u0010\u0013\u001a\b\u0012\u0004\u0012\u0002H\u00120\u0014H\u0086Hø\u0001\u0000\u0082\u0002\n\n\b\b\u0001\u0012\u0002\u0010\u0001 \u0001¢\u0006\u0002\u0010\u0015\"\u000e\u0010\u0000\u001a\u00020\u0001X\u0082\u0004¢\u0006\u0002\n\u0000\"\u000e\u0010\u0002\u001a\u00020\u0001X\u0082\u0004¢\u0006\u0002\n\u0000\"\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u0004¢\u0006\u0002\n\u0000\"\u000e\u0010\u0005\u001a\u00020\u0001X\u0082\u0004¢\u0006\u0002\n\u0000\"\u000e\u0010\u0006\u001a\u00020\u0004X\u0082\u0004¢\u0006\u0002\n\u0000\"\u000e\u0010\u0007\u001a\u00020\u0001X\u0082\u0004¢\u0006\u0002\n\u0000\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\u0016"}, d2 = {"BROKEN", "Lkotlinx/coroutines/internal/Symbol;", "CANCELLED", "MAX_SPIN_CYCLES", "", "PERMIT", "SEGMENT_SIZE", "TAKEN", "Semaphore", "Lkotlinx/coroutines/sync/Semaphore;", "permits", "acquiredPermits", "createSegment", "Lkotlinx/coroutines/sync/SemaphoreSegment;", "id", "", "prev", "withPermit", "T", "action", "Lkotlin/Function0;", "(Lkotlinx/coroutines/sync/Semaphore;Lkotlin/jvm/functions/Function0;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "kotlinx-coroutines-core"}, k = 2, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public final class SemaphoreKt {
private static final Symbol BROKEN;
private static final Symbol CANCELLED;
private static final int MAX_SPIN_CYCLES;
private static final Symbol PERMIT;
private static final int SEGMENT_SIZE;
private static final Symbol TAKEN;
public static final Semaphore Semaphore(int i, int i2) {
return new SemaphoreImpl(i, i2);
}
public static /* synthetic */ Semaphore Semaphore$default(int i, int i2, int i3, Object obj) {
if ((i3 & 2) != 0) {
i2 = 0;
}
return Semaphore(i, i2);
}
/* JADX WARN: Removed duplicated region for block: B:21:0x003b */
/* JADX WARN: Removed duplicated region for block: B:8:0x0024 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static final <T> java.lang.Object withPermit(kotlinx.coroutines.sync.Semaphore r4, kotlin.jvm.functions.Function0<? extends T> r5, kotlin.coroutines.Continuation<? super T> r6) {
/*
boolean r0 = r6 instanceof kotlinx.coroutines.sync.SemaphoreKt$withPermit$1
if (r0 == 0) goto L14
r0 = r6
kotlinx.coroutines.sync.SemaphoreKt$withPermit$1 r0 = (kotlinx.coroutines.sync.SemaphoreKt$withPermit$1) r0
int r1 = r0.label
r2 = -2147483648(0xffffffff80000000, float:-0.0)
r1 = r1 & r2
if (r1 == 0) goto L14
int r6 = r0.label
int r6 = r6 - r2
r0.label = r6
goto L19
L14:
kotlinx.coroutines.sync.SemaphoreKt$withPermit$1 r0 = new kotlinx.coroutines.sync.SemaphoreKt$withPermit$1
r0.<init>(r6)
L19:
java.lang.Object r6 = r0.result
java.lang.Object r1 = kotlin.coroutines.intrinsics.IntrinsicsKt.getCOROUTINE_SUSPENDED()
int r2 = r0.label
r3 = 1
if (r2 == 0) goto L3b
if (r2 != r3) goto L33
java.lang.Object r4 = r0.L$1
r5 = r4
kotlin.jvm.functions.Function0 r5 = (kotlin.jvm.functions.Function0) r5
java.lang.Object r4 = r0.L$0
kotlinx.coroutines.sync.Semaphore r4 = (kotlinx.coroutines.sync.Semaphore) r4
kotlin.ResultKt.throwOnFailure(r6)
goto L4b
L33:
java.lang.IllegalStateException r4 = new java.lang.IllegalStateException
java.lang.String r5 = "call to 'resume' before 'invoke' with coroutine"
r4.<init>(r5)
throw r4
L3b:
kotlin.ResultKt.throwOnFailure(r6)
r0.L$0 = r4
r0.L$1 = r5
r0.label = r3
java.lang.Object r6 = r4.acquire(r0)
if (r6 != r1) goto L4b
return r1
L4b:
java.lang.Object r5 = r5.invoke() // Catch: java.lang.Throwable -> L59
kotlin.jvm.internal.InlineMarker.finallyStart(r3)
r4.release()
kotlin.jvm.internal.InlineMarker.finallyEnd(r3)
return r5
L59:
r5 = move-exception
kotlin.jvm.internal.InlineMarker.finallyStart(r3)
r4.release()
kotlin.jvm.internal.InlineMarker.finallyEnd(r3)
throw r5
*/
throw new UnsupportedOperationException("Method not decompiled: kotlinx.coroutines.sync.SemaphoreKt.withPermit(kotlinx.coroutines.sync.Semaphore, kotlin.jvm.functions.Function0, kotlin.coroutines.Continuation):java.lang.Object");
}
private static final <T> Object withPermit$$forInline(Semaphore semaphore, Function0<? extends T> function0, Continuation<? super T> continuation) {
InlineMarker.mark(0);
semaphore.acquire(continuation);
InlineMarker.mark(1);
try {
return function0.invoke();
} finally {
InlineMarker.finallyStart(1);
semaphore.release();
InlineMarker.finallyEnd(1);
}
}
/* JADX INFO: Access modifiers changed from: private */
public static final SemaphoreSegment createSegment(long j, SemaphoreSegment semaphoreSegment) {
return new SemaphoreSegment(j, semaphoreSegment, 0);
}
static {
int systemProp$default;
int systemProp$default2;
systemProp$default = SystemPropsKt__SystemProps_commonKt.systemProp$default("kotlinx.coroutines.semaphore.maxSpinCycles", 100, 0, 0, 12, (Object) null);
MAX_SPIN_CYCLES = systemProp$default;
PERMIT = new Symbol("PERMIT");
TAKEN = new Symbol("TAKEN");
BROKEN = new Symbol("BROKEN");
CANCELLED = new Symbol("CANCELLED");
systemProp$default2 = SystemPropsKt__SystemProps_commonKt.systemProp$default("kotlinx.coroutines.semaphore.segmentSize", 16, 0, 0, 12, (Object) null);
SEGMENT_SIZE = systemProp$default2;
}
}

View File

@ -0,0 +1,61 @@
package kotlinx.coroutines.sync;
import java.util.concurrent.atomic.AtomicReferenceArray;
import kotlin.Metadata;
import kotlin.coroutines.CoroutineContext;
import kotlinx.coroutines.channels.ChannelSegment$$ExternalSyntheticBackportWithForwarding0;
import kotlinx.coroutines.internal.Segment;
import kotlinx.coroutines.internal.Symbol;
/* compiled from: Semaphore.kt */
@Metadata(d1 = {"\u0000H\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0002\b\u0006\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0003\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\b\u0002\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\u001f\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\b\u0010\u0004\u001a\u0004\u0018\u00010\u0000\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007J%\u0010\u000e\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00020\u00062\b\u0010\u0011\u001a\u0004\u0018\u00010\n2\b\u0010\u0012\u001a\u0004\u0018\u00010\nH\u0086\bJ\u0013\u0010\u0013\u001a\u0004\u0018\u00010\n2\u0006\u0010\u0010\u001a\u00020\u0006H\u0086\bJ\u001d\u0010\u0014\u001a\u0004\u0018\u00010\n2\u0006\u0010\u0010\u001a\u00020\u00062\b\u0010\u0012\u001a\u0004\u0018\u00010\nH\u0086\bJ\"\u0010\u0015\u001a\u00020\u00162\u0006\u0010\u0010\u001a\u00020\u00062\b\u0010\u0017\u001a\u0004\u0018\u00010\u00182\u0006\u0010\u0019\u001a\u00020\u001aH\u0016J\u001b\u0010\u001b\u001a\u00020\u00162\u0006\u0010\u0010\u001a\u00020\u00062\b\u0010\u0012\u001a\u0004\u0018\u00010\nH\u0086\bJ\b\u0010\u001c\u001a\u00020\u001dH\u0016R\u000e\u0010\b\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\n0\tR\u0014\u0010\u000b\u001a\u00020\u00068VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\f\u0010\\u0006\u001e"}, d2 = {"Lkotlinx/coroutines/sync/SemaphoreSegment;", "Lkotlinx/coroutines/internal/Segment;", "id", "", "prev", "pointers", "", "(JLkotlinx/coroutines/sync/SemaphoreSegment;I)V", "acquirers", "Lkotlinx/atomicfu/AtomicArray;", "", "numberOfSlots", "getNumberOfSlots", "()I", "cas", "", "index", "expected", "value", "get", "getAndSet", "onCancellation", "", "cause", "", "context", "Lkotlin/coroutines/CoroutineContext;", "set", "toString", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
final class SemaphoreSegment extends Segment<SemaphoreSegment> {
private final AtomicReferenceArray acquirers;
public final AtomicReferenceArray getAcquirers() {
return this.acquirers;
}
public SemaphoreSegment(long j, SemaphoreSegment semaphoreSegment, int i) {
super(j, semaphoreSegment, i);
int i2;
i2 = SemaphoreKt.SEGMENT_SIZE;
this.acquirers = new AtomicReferenceArray(i2);
}
@Override // kotlinx.coroutines.internal.Segment
public int getNumberOfSlots() {
int i;
i = SemaphoreKt.SEGMENT_SIZE;
return i;
}
public final Object get(int index) {
return getAcquirers().get(index);
}
public final void set(int index, Object value) {
getAcquirers().set(index, value);
}
public final boolean cas(int index, Object expected, Object value) {
return ChannelSegment$$ExternalSyntheticBackportWithForwarding0.m(getAcquirers(), index, expected, value);
}
public final Object getAndSet(int index, Object value) {
return getAcquirers().getAndSet(index, value);
}
@Override // kotlinx.coroutines.internal.Segment
public void onCancellation(int index, Throwable cause, CoroutineContext context) {
Symbol symbol;
symbol = SemaphoreKt.CANCELLED;
getAcquirers().set(index, symbol);
onSlotCleaned();
}
public String toString() {
return "SemaphoreSegment[id=" + this.id + ", hashCode=" + hashCode() + ']';
}
}