package kotlinx.coroutines.o2;

import kotlinx.coroutines.i2;

/* JADX INFO: compiled from: ThreadContext.kt */
/* JADX INFO: loaded from: classes.dex */
final class x {
    public final h.u.g a;
    private final Object[] b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final i2<Object>[] f1122c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private int f1123d;

    public x(h.u.g gVar, int i2) {
        this.a = gVar;
        this.b = new Object[i2];
        this.f1122c = new i2[i2];
    }

    public final void a(i2<?> i2Var, Object obj) {
        Object[] objArr = this.b;
        int i2 = this.f1123d;
        objArr[i2] = obj;
        i2<Object>[] i2VarArr = this.f1122c;
        this.f1123d = i2 + 1;
        i2VarArr[i2] = i2Var;
    }

    public final void b(h.u.g gVar) {
        int length = this.f1122c.length - 1;
        if (length < 0) {
            return;
        }
        while (true) {
            int i2 = length - 1;
            i2<Object> i2Var = this.f1122c[length];
            h.x.d.k.b(i2Var);
            i2Var.m(gVar, this.b[length]);
            if (i2 < 0) {
                return;
            } else {
                length = i2;
            }
        }
    }
}
