Class HalfSerializer

java.lang.Object
io.reactivex.rxjava3.internal.util.HalfSerializer

public final class HalfSerializer extends Object
Utility methods to perform 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.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Utility class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    onComplete(Observer<?> observer, AtomicInteger wip, AtomicThrowable errors)
    Emits an onComplete signal or an onError signal with the given error or indicates the concurrently running onNext should do that.
    static void
    onComplete(org.reactivestreams.Subscriber<?> subscriber, AtomicInteger wip, AtomicThrowable errors)
    Emits an onComplete signal or an onError signal with the given error or indicates the concurrently running onNext should do that.
    static void
    onError(Observer<?> observer, Throwable ex, AtomicInteger wip, AtomicThrowable errors)
    Emits the given exception if possible or adds it to the given error container to be emitted by a concurrent onNext if one is running.
    static void
    onError(org.reactivestreams.Subscriber<?> subscriber, Throwable ex, AtomicInteger wip, AtomicThrowable errors)
    Emits the given exception if possible or adds it to the given error container to be emitted by a concurrent onNext if one is running.
    static <T> void
    onNext(Observer<? super T> observer, T value, AtomicInteger wip, AtomicThrowable errors)
    Emits the given value if possible and terminates if there was an onComplete or onError while emitting, drops the value otherwise.
    static <T> boolean
    onNext(org.reactivestreams.Subscriber<? super T> subscriber, T value, AtomicInteger wip, AtomicThrowable errors)
    Emits the given value if possible and terminates if there was an onComplete or onError while emitting, drops the value otherwise.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HalfSerializer

      private HalfSerializer()
      Utility class.
  • Method Details

    • onNext

      public static <T> boolean onNext(org.reactivestreams.Subscriber<? super T> subscriber, T value, AtomicInteger wip, AtomicThrowable errors)
      Emits the given value if possible and terminates if there was an onComplete or onError while emitting, drops the value otherwise.
      Type Parameters:
      T - the value type
      Parameters:
      subscriber - the target Subscriber to emit to
      value - the value to emit
      wip - the serialization work-in-progress counter/indicator
      errors - the holder of Throwables
      Returns:
      true if the operation succeeded, false if there sequence completed
    • onError

      public static void onError(org.reactivestreams.Subscriber<?> subscriber, Throwable ex, AtomicInteger wip, AtomicThrowable errors)
      Emits the given exception if possible or adds it to the given error container to be emitted by a concurrent onNext if one is running. Undeliverable exceptions are sent to the RxJavaPlugins.onError.
      Parameters:
      subscriber - the target Subscriber to emit to
      ex - the Throwable to emit
      wip - the serialization work-in-progress counter/indicator
      errors - the holder of Throwables
    • onComplete

      public static void onComplete(org.reactivestreams.Subscriber<?> subscriber, AtomicInteger wip, AtomicThrowable errors)
      Emits an onComplete signal or an onError signal with the given error or indicates the concurrently running onNext should do that.
      Parameters:
      subscriber - the target Subscriber to emit to
      wip - the serialization work-in-progress counter/indicator
      errors - the holder of Throwables
    • onNext

      public static <T> void onNext(Observer<? super T> observer, T value, AtomicInteger wip, AtomicThrowable errors)
      Emits the given value if possible and terminates if there was an onComplete or onError while emitting, drops the value otherwise.
      Type Parameters:
      T - the value type
      Parameters:
      observer - the target Observer to emit to
      value - the value to emit
      wip - the serialization work-in-progress counter/indicator
      errors - the holder of Throwables
    • onError

      public static void onError(Observer<?> observer, Throwable ex, AtomicInteger wip, AtomicThrowable errors)
      Emits the given exception if possible or adds it to the given error container to be emitted by a concurrent onNext if one is running. Undeliverable exceptions are sent to the RxJavaPlugins.onError.
      Parameters:
      observer - the target Subscriber to emit to
      ex - the Throwable to emit
      wip - the serialization work-in-progress counter/indicator
      errors - the holder of Throwables
    • onComplete

      public static void onComplete(Observer<?> observer, AtomicInteger wip, AtomicThrowable errors)
      Emits an onComplete signal or an onError signal with the given error or indicates the concurrently running onNext should do that.
      Parameters:
      observer - the target Subscriber to emit to
      wip - the serialization work-in-progress counter/indicator
      errors - the holder of Throwables