package io.reactivex.internal.operators.observable;

import java.util.concurrent.atomic.AtomicInteger;
import 㴹.K.AbstractC2520;
import 㴹.K.Ԕ.ʬ.AbstractC2432;

public final class ObservableScalarXMap$ScalarDisposable<T> extends AtomicInteger implements AbstractC2432<T>, Runnable {
    public static final int FUSED = 1;
    public static final int ON_COMPLETE = 3;
    public static final int ON_NEXT = 2;
    public static final int START = 0;
    public static final long serialVersionUID = 3880992722410194083L;
    public final AbstractC2520<? super T> observer;
    public final T value;

    public ObservableScalarXMap$ScalarDisposable(AbstractC2520<? super T> r1, T t) {
        this.observer = r1;
        this.value = t;
    }

    @Override // 㴹.K.Ԕ.ʬ.AbstractC2439
    public void clear() {
        lazySet(3);
    }

    @Override // 㴹.K.㑃.AbstractC2514
    public void dispose() {
        set(3);
    }

    @Override // 㴹.K.㑃.AbstractC2514
    public boolean isDisposed() {
        return get() == 3;
    }

    @Override // 㴹.K.Ԕ.ʬ.AbstractC2439
    public boolean isEmpty() {
        return get() != 1;
    }

    @Override // 㴹.K.Ԕ.ʬ.AbstractC2439
    public boolean offer(T t) {
        throw new UnsupportedOperationException("Should not be called!");
    }

    @Override // 㴹.K.Ԕ.ʬ.AbstractC2439
    public T poll() throws Exception {
        if (get() != 1) {
            return null;
        }
        lazySet(3);
        return this.value;
    }

    @Override // 㴹.K.Ԕ.ʬ.AbstractC2438
    public int requestFusion(int i) {
        if ((i & 1) == 0) {
            return 0;
        }
        lazySet(1);
        return 1;
    }

    public void run() {
        if (get() == 0 && compareAndSet(0, 2)) {
            this.observer.onNext(this.value);
            if (get() == 2) {
                lazySet(3);
                this.observer.onComplete();
            }
        }
    }

    public boolean offer(T t, T t2) {
        throw new UnsupportedOperationException("Should not be called!");
    }
}
