Class HalfSerializer
java.lang.Object
io.reactivex.rxjava3.internal.util.HalfSerializer
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic voidonComplete(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 voidonComplete(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 voidonError(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 voidonError(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> voidonNext(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> booleanonNext(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.
-
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 tovalue- the value to emitwip- the serialization work-in-progress counter/indicatorerrors- 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 toex- the Throwable to emitwip- the serialization work-in-progress counter/indicatorerrors- 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 towip- the serialization work-in-progress counter/indicatorerrors- 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 tovalue- the value to emitwip- the serialization work-in-progress counter/indicatorerrors- 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 toex- the Throwable to emitwip- the serialization work-in-progress counter/indicatorerrors- the holder of Throwables
-
onComplete
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 towip- the serialization work-in-progress counter/indicatorerrors- the holder of Throwables
-