package kotlinx.coroutines.flow; import androidx.concurrent.futures.AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import kotlin.Result; import kotlin.Unit; import kotlin.coroutines.Continuation; 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.flow.internal.AbstractSharedFlowKt; import kotlinx.coroutines.flow.internal.AbstractSharedFlowSlot; import kotlinx.coroutines.internal.Symbol; /* loaded from: classes5.dex */ public final class StateFlowSlot extends AbstractSharedFlowSlot { public static final AtomicReferenceFieldUpdater _state$FU = AtomicReferenceFieldUpdater.newUpdater(StateFlowSlot.class, Object.class, "_state"); private volatile Object _state; @Override // kotlinx.coroutines.flow.internal.AbstractSharedFlowSlot public boolean allocateLocked(StateFlowImpl stateFlowImpl) { Symbol symbol; AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = _state$FU; if (atomicReferenceFieldUpdater.get(this) != null) { return false; } symbol = StateFlowKt.NONE; atomicReferenceFieldUpdater.set(this, symbol); return true; } @Override // kotlinx.coroutines.flow.internal.AbstractSharedFlowSlot public Continuation[] freeLocked(StateFlowImpl stateFlowImpl) { _state$FU.set(this, null); return AbstractSharedFlowKt.EMPTY_RESUMES; } public final void makePending() { Symbol symbol; Symbol symbol2; Symbol symbol3; Symbol symbol4; AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = _state$FU; while (true) { Object obj = atomicReferenceFieldUpdater.get(this); if (obj == null) { return; } symbol = StateFlowKt.PENDING; if (obj == symbol) { return; } symbol2 = StateFlowKt.NONE; if (obj == symbol2) { AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = _state$FU; symbol3 = StateFlowKt.PENDING; if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater2, this, obj, symbol3)) { return; } } else { AtomicReferenceFieldUpdater atomicReferenceFieldUpdater3 = _state$FU; symbol4 = StateFlowKt.NONE; if (AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater3, this, obj, symbol4)) { Result.Companion companion = Result.Companion; ((CancellableContinuationImpl) obj).resumeWith(Result.m4060constructorimpl(Unit.INSTANCE)); return; } } } } public final boolean takePending() { Symbol symbol; Symbol symbol2; AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = _state$FU; symbol = StateFlowKt.NONE; Object andSet = atomicReferenceFieldUpdater.getAndSet(this, symbol); Intrinsics.checkNotNull(andSet); symbol2 = StateFlowKt.PENDING; return andSet == symbol2; } public final Object awaitPending(Continuation continuation) { Continuation intercepted; Symbol symbol; Object coroutine_suspended; Object coroutine_suspended2; intercepted = IntrinsicsKt__IntrinsicsJvmKt.intercepted(continuation); CancellableContinuationImpl cancellableContinuationImpl = new CancellableContinuationImpl(intercepted, 1); cancellableContinuationImpl.initCancellability(); AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = _state$FU; symbol = StateFlowKt.NONE; if (!AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, symbol, cancellableContinuationImpl)) { Result.Companion companion = Result.Companion; cancellableContinuationImpl.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; } }