Class HalfSerializer


  • public final class HalfSerializer
    extends java.lang.Object
    Methods to implement half-serialization: a form of serialization where onNext is guaranteed to be called from a single thread but onError or onComplete may be called from any threads.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void onComplete​(org.reactivestreams.Subscriber<?> subscriber, java.util.concurrent.atomic.AtomicInteger wip, java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> container)
      Propagates the completion event or failure events (if a failure is stored in the container).
      static void onError​(org.reactivestreams.Subscriber<?> subscriber, java.lang.Throwable failure, java.util.concurrent.atomic.AtomicInteger wip, java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> container)
      Propagates the given failure if the downstream if possible (no work in progress) or accumulate it to the given failure container to be propagated by a concurrent onNext call.
      static <T> void onNext​(org.reactivestreams.Subscriber<? super T> subscriber, T item, java.util.concurrent.atomic.AtomicInteger wip, java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> container)
      Propagates the given item if possible and terminates if there was a completion or failure event happening during the propagation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • onNext

        public static <T> void onNext​(org.reactivestreams.Subscriber<? super T> subscriber,
                                      T item,
                                      java.util.concurrent.atomic.AtomicInteger wip,
                                      java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> container)
        Propagates the given item if possible and terminates if there was a completion or failure event happening during the propagation. The item is drops is the downstream already got a terminal event.
        Type Parameters:
        T - the type of the item
        Parameters:
        subscriber - the downstream subscriber
        item - the item to propagate downstream
        wip - the serialization work-in-progress counter
        container - the failure container
      • onError

        public static void onError​(org.reactivestreams.Subscriber<?> subscriber,
                                   java.lang.Throwable failure,
                                   java.util.concurrent.atomic.AtomicInteger wip,
                                   java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> container)
        Propagates the given failure if the downstream if possible (no work in progress) or accumulate it to the given failure container to be propagated by a concurrent onNext call.
        Parameters:
        subscriber - the downstream subscriber
        failure - the failure event to propagate
        wip - the serialization work-in-progress counter
        container - the failure container
      • onComplete

        public static void onComplete​(org.reactivestreams.Subscriber<?> subscriber,
                                      java.util.concurrent.atomic.AtomicInteger wip,
                                      java.util.concurrent.atomic.AtomicReference<java.lang.Throwable> container)
        Propagates the completion event or failure events (if a failure is stored in the container). If the event cannot be dispatched, a concurrent onNext will.
        Parameters:
        subscriber - the downstream subscriber
        wip - the serialization work-in-progress counter
        container - the failure container