jimu-decompiled/sources/org/greenrobot/eventbus/HandlerPoster.java
2025-05-13 19:24:51 +02:00

61 lines
1.7 KiB
Java

package org.greenrobot.eventbus;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
/* loaded from: classes2.dex */
final class HandlerPoster extends Handler {
private final PendingPostQueue a;
private final int b;
private final EventBus c;
private boolean d;
HandlerPoster(EventBus eventBus, Looper looper, int i) {
super(looper);
this.c = eventBus;
this.b = i;
this.a = new PendingPostQueue();
}
void a(Subscription subscription, Object obj) {
PendingPost a = PendingPost.a(subscription, obj);
synchronized (this) {
this.a.a(a);
if (!this.d) {
this.d = true;
if (!sendMessage(obtainMessage())) {
throw new EventBusException("Could not send handler message");
}
}
}
}
@Override // android.os.Handler
public void handleMessage(Message message) {
try {
long uptimeMillis = SystemClock.uptimeMillis();
do {
PendingPost a = this.a.a();
if (a == null) {
synchronized (this) {
a = this.a.a();
if (a == null) {
this.d = false;
return;
}
}
}
this.c.a(a);
} while (SystemClock.uptimeMillis() - uptimeMillis < this.b);
if (!sendMessage(obtainMessage())) {
throw new EventBusException("Could not send handler message");
}
this.d = true;
} finally {
this.d = false;
}
}
}