package org.greenrobot.eventbus;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;

/* JADX INFO: compiled from: HandlerPoster.java */
/* JADX INFO: loaded from: classes.dex */
final class f extends Handler {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final i f3358a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final int f3359b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final c f3360c;

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

    f(c cVar, Looper looper, int i) {
        super(looper);
        this.f3360c = cVar;
        this.f3359b = i;
        this.f3358a = new i();
    }

    void a(n nVar, Object obj) {
        h hVarA = h.a(nVar, obj);
        synchronized (this) {
            this.f3358a.a(hVarA);
            if (!this.f3361d) {
                this.f3361d = true;
                if (!sendMessage(obtainMessage())) {
                    throw new e("Could not send handler message");
                }
            }
        }
    }

    @Override // android.os.Handler
    public void handleMessage(Message message) {
        try {
            long jUptimeMillis = SystemClock.uptimeMillis();
            do {
                h hVarB = this.f3358a.b();
                if (hVarB == null) {
                    synchronized (this) {
                        hVarB = this.f3358a.b();
                        if (hVarB == null) {
                            this.f3361d = false;
                            return;
                        }
                    }
                }
                this.f3360c.f(hVarB);
            } while (SystemClock.uptimeMillis() - jUptimeMillis < this.f3359b);
            if (!sendMessage(obtainMessage())) {
                throw new e("Could not send handler message");
            }
            this.f3361d = true;
        } finally {
            this.f3361d = false;
        }
    }
}
