package Z6;

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

/* JADX INFO: loaded from: classes.dex */
public abstract class Q implements Runnable, Comparable, L {
    private volatile Object _heap;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public long f7482q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f7483r = -1;

    public Q(long j8) {
        this.f7482q = j8;
    }

    public final e7.w a() {
        Object obj = this._heap;
        if (obj instanceof e7.w) {
            return (e7.w) obj;
        }
        return null;
    }

    @Override // Z6.L
    public final void b() {
        synchronized (this) {
            try {
                Object obj = this._heap;
                B3.f fVar = AbstractC0385z.f7565b;
                if (obj == fVar) {
                    return;
                }
                S s8 = obj instanceof S ? (S) obj : null;
                if (s8 != null) {
                    s8.b(this);
                }
                this._heap = fVar;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // java.lang.Comparable
    public final int compareTo(Object obj) {
        long j8 = this.f7482q - ((Q) obj).f7482q;
        if (j8 > 0) {
            return 1;
        }
        return j8 < 0 ? -1 : 0;
    }

    public final int d(long j8, S s8, T t6) {
        synchronized (this) {
            if (this._heap == AbstractC0385z.f7565b) {
                return 2;
            }
            synchronized (s8) {
                try {
                    Q[] qArr = s8.f12582a;
                    Q q8 = qArr != null ? qArr[0] : null;
                    AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = T.f7485w;
                    t6.getClass();
                    if (T.f7487y.get(t6) == 1) {
                        return 1;
                    }
                    if (q8 == null) {
                        s8.f7484c = j8;
                    } else {
                        long j9 = q8.f7482q;
                        if (j9 - j8 < 0) {
                            j8 = j9;
                        }
                        if (j8 - s8.f7484c > 0) {
                            s8.f7484c = j8;
                        }
                    }
                    long j10 = this.f7482q;
                    long j11 = s8.f7484c;
                    if (j10 - j11 < 0) {
                        this.f7482q = j11;
                    }
                    s8.a(this);
                    return 0;
                } catch (Throwable th) {
                    throw th;
                }
            }
        }
    }

    public final void e(S s8) {
        if (this._heap == AbstractC0385z.f7565b) {
            throw new IllegalArgumentException("Failed requirement.");
        }
        this._heap = s8;
    }

    public String toString() {
        return "Delayed[nanos=" + this.f7482q + ']';
    }
}
