package io.reactivex.internal.util; import io.reactivex.Observer; import io.reactivex.plugins.RxJavaPlugins; import java.util.concurrent.atomic.AtomicInteger; import org.reactivestreams.Subscriber; /* loaded from: classes2.dex */ public final class HalfSerializer { /* JADX WARN: Multi-variable type inference failed */ public static void a(Subscriber subscriber, T t, AtomicInteger atomicInteger, AtomicThrowable atomicThrowable) { if (atomicInteger.get() == 0 && atomicInteger.compareAndSet(0, 1)) { subscriber.onNext(t); if (atomicInteger.decrementAndGet() != 0) { Throwable terminate = atomicThrowable.terminate(); if (terminate != null) { subscriber.onError(terminate); } else { subscriber.onComplete(); } } } } public static void a(Subscriber subscriber, Throwable th, AtomicInteger atomicInteger, AtomicThrowable atomicThrowable) { if (atomicThrowable.addThrowable(th)) { if (atomicInteger.getAndIncrement() == 0) { subscriber.onError(atomicThrowable.terminate()); return; } return; } RxJavaPlugins.b(th); } public static void a(Subscriber subscriber, AtomicInteger atomicInteger, AtomicThrowable atomicThrowable) { if (atomicInteger.getAndIncrement() == 0) { Throwable terminate = atomicThrowable.terminate(); if (terminate != null) { subscriber.onError(terminate); } else { subscriber.onComplete(); } } } /* JADX WARN: Multi-variable type inference failed */ public static void a(Observer observer, T t, AtomicInteger atomicInteger, AtomicThrowable atomicThrowable) { if (atomicInteger.get() == 0 && atomicInteger.compareAndSet(0, 1)) { observer.onNext(t); if (atomicInteger.decrementAndGet() != 0) { Throwable terminate = atomicThrowable.terminate(); if (terminate != null) { observer.onError(terminate); } else { observer.onComplete(); } } } } public static void a(Observer observer, Throwable th, AtomicInteger atomicInteger, AtomicThrowable atomicThrowable) { if (atomicThrowable.addThrowable(th)) { if (atomicInteger.getAndIncrement() == 0) { observer.onError(atomicThrowable.terminate()); return; } return; } RxJavaPlugins.b(th); } public static void a(Observer observer, AtomicInteger atomicInteger, AtomicThrowable atomicThrowable) { if (atomicInteger.getAndIncrement() == 0) { Throwable terminate = atomicThrowable.terminate(); if (terminate != null) { observer.onError(terminate); } else { observer.onComplete(); } } } }