src/main/java/io/reactivex/internal/subscriptions/DeferredScalarSubscription.java
public final void complete(T v) {
        int state = get();
        for (;;) {
            if (state == FUSED_EMPTY) {
                value = v;
                lazySet(FUSED_READY);

                Subscriber<? super T> a = downstream;
                a.onNext(v);
                if (get() != CANCELLED) {
                    a.onComplete();
                }
                return;
            }

            // if state is >= CANCELLED or bit zero is set (*_HAS_VALUE) case, return
            if ((state & ~HAS_REQUEST_NO_VALUE) != 0) {
                return;
            }

            if (state == HAS_REQUEST_NO_VALUE) {
                lazySet(HAS_REQUEST_HAS_VALUE);
                Subscriber<? super T> a = downstream;
                a.onNext(v);
                if (get() != CANCELLED) {
                    a.onComplete();
                }
                return;
            }
            value = v;
            if (compareAndSet(NO_REQUEST_NO_VALUE, NO_REQUEST_HAS_VALUE)) {
                return;
            }
            state = get();
            if (state == CANCELLED) {
                value = null;
                return;
            }
        }
    }
public final void complete(T v) {
        int state = get();
        for (;;) {
            if (state == FUSED_EMPTY) {
                value = v;
                lazySet(FUSED_READY);

                Subscriber<? super T> a = downstream;
                a.onNext(v);
                if (get() != CANCELLED) {
                    a.onComplete();
                }
                return;
            }

            // if state is >= CANCELLED or bit zero is set (*_HAS_VALUE) case, return
            if ((state & ~HAS_REQUEST_NO_VALUE) != 0) {
                return;
            }

            if (state == HAS_REQUEST_NO_VALUE) {
                lazySet(HAS_REQUEST_HAS_VALUE);
                Subscriber<? super T> a = downstream;
                a.onNext(v);
                if (get() != CANCELLED) {
                    a.onComplete();
                }
                return;
            }
            value = v;
            if (compareAndSet(NO_REQUEST_NO_VALUE, NO_REQUEST_HAS_VALUE)) {
                return;
            }
            state = get();
            if (state == CANCELLED) {
                value = null;
                return;
            }
        }
    }
public final void complete ( T v ) { int state = get ( ) ; for ( ; ; ) { if ( state == FUSED_EMPTY ) { value = v ; lazySet ( FUSED_READY ) ; Subscriber < ? super T > a = downstream ; a . onNext ( v ) ; if ( get ( ) != CANCELLED ) { a . onComplete ( ) ; } return ; } // if state is >= CANCELLED or bit zero is set (*_HAS_VALUE) case, return if ( ( state & ~ HAS_REQUEST_NO_VALUE ) != 0 ) { return ; } if ( state == HAS_REQUEST_NO_VALUE ) { lazySet ( HAS_REQUEST_HAS_VALUE ) ; Subscriber < ? super T > a = downstream ; a . onNext ( v ) ; if ( get ( ) != CANCELLED ) { a . onComplete ( ) ; } return ; } value = v ; if ( compareAndSet ( NO_REQUEST_NO_VALUE , NO_REQUEST_HAS_VALUE ) ) { return ; } state = get ( ) ; if ( state == CANCELLED ) { value = null ; return ; } } }
Completes this subscription by indicating the given value should
be emitted when the first request arrives.
<p>Make sure this is called exactly once.
@param v the value to signal, not null (not validated)
Completes this subscription by indicating the given value should be emitted when the first request arrives . <p > Make sure this is called exactly once .