src/main/java/io/reactivex/internal/util/HalfSerializer.java
public static void onComplete(Subscriber<?> subscriber, AtomicInteger wip, AtomicThrowable error) {
        if (wip.getAndIncrement() == 0) {
            Throwable ex = error.terminate();
            if (ex != null) {
                subscriber.onError(ex);
            } else {
                subscriber.onComplete();
            }
        }
    }
public static void onComplete(Subscriber<?> subscriber, AtomicInteger wip, AtomicThrowable error) {
        if (wip.getAndIncrement() == 0) {
            Throwable ex = error.terminate();
            if (ex != null) {
                subscriber.onError(ex);
            } else {
                subscriber.onComplete();
            }
        }
    }
Emits an onComplete signal or an onError signal with the given error or indicates
the concurrently running onNext should do that.
@param subscriber the target Subscriber to emit to
@param wip the serialization work-in-progress counter/indicator
@param error the holder of Throwables