Package io.reactivex.rxjava3.subscribers
Class SerializedSubscriber<T>
- java.lang.Object
-
- io.reactivex.rxjava3.subscribers.SerializedSubscriber<T>
-
- Type Parameters:
T- the value type
- All Implemented Interfaces:
FlowableSubscriber<T>,org.reactivestreams.Subscriber<T>,org.reactivestreams.Subscription
public final class SerializedSubscriber<T> extends java.lang.Object implements FlowableSubscriber<T>, org.reactivestreams.Subscription
Serializes access to theSubscriber.onNext(Object),Subscriber.onError(Throwable)andSubscriber.onComplete()methods of anotherSubscriber.Note that
onSubscribe(Subscription)is not serialized in respect of the other methods so make sure theonSubscribeis called with a non-nullSubscriptionbefore any of the other methods are called.The implementation assumes that the actual
Subscriber's methods don't throw.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) booleandelayError(package private) booleandone(package private) org.reactivestreams.Subscriber<? super T>downstream(package private) booleanemitting(package private) AppendOnlyLinkedArrayList<java.lang.Object>queue(package private) static intQUEUE_LINK_SIZE(package private) org.reactivestreams.Subscriptionupstream
-
Constructor Summary
Constructors Constructor Description SerializedSubscriber(@NonNull org.reactivestreams.Subscriber<? super T> actual, boolean delayError)Construct aSerializedSubscriberby wrapping the given actualSubscriberand optionally delaying the errors till all regular values have been emitted from the internal buffer.SerializedSubscriber(org.reactivestreams.Subscriber<? super T> downstream)Construct aSerializedSubscriberby wrapping the given actualSubscriber.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()(package private) voidemitLoop()voidonComplete()voidonError(java.lang.Throwable t)voidonNext(T t)voidonSubscribe(@NonNull org.reactivestreams.Subscription s)Implementors of this method should make sure everything that needs to be visible inSubscriber.onNext(Object)is established before callingSubscription.request(long).voidrequest(long n)
-
-
-
Field Detail
-
downstream
final org.reactivestreams.Subscriber<? super T> downstream
-
delayError
final boolean delayError
-
QUEUE_LINK_SIZE
static final int QUEUE_LINK_SIZE
- See Also:
- Constant Field Values
-
upstream
org.reactivestreams.Subscription upstream
-
emitting
boolean emitting
-
queue
AppendOnlyLinkedArrayList<java.lang.Object> queue
-
done
volatile boolean done
-
-
Constructor Detail
-
SerializedSubscriber
public SerializedSubscriber(org.reactivestreams.Subscriber<? super T> downstream)
Construct aSerializedSubscriberby wrapping the given actualSubscriber.- Parameters:
downstream- the actualSubscriber, not null (not verified)
-
SerializedSubscriber
public SerializedSubscriber(@NonNull @NonNull org.reactivestreams.Subscriber<? super T> actual, boolean delayError)
Construct aSerializedSubscriberby wrapping the given actualSubscriberand optionally delaying the errors till all regular values have been emitted from the internal buffer.- Parameters:
actual- the actualSubscriber, notnull(not verified)delayError- iftrue, errors are emitted after regular values have been emitted
-
-
Method Detail
-
onSubscribe
public void onSubscribe(@NonNull @NonNull org.reactivestreams.Subscription s)
Description copied from interface:FlowableSubscriberImplementors of this method should make sure everything that needs to be visible inSubscriber.onNext(Object)is established before callingSubscription.request(long). In practice this means no initialization should happen after therequest()call and additional behavior is thread safe in respect toonNext.- Specified by:
onSubscribein interfaceFlowableSubscriber<T>- Specified by:
onSubscribein interfaceorg.reactivestreams.Subscriber<T>
-
onNext
public void onNext(@NonNull T t)
- Specified by:
onNextin interfaceorg.reactivestreams.Subscriber<T>
-
onError
public void onError(java.lang.Throwable t)
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public void onComplete()
- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<T>
-
emitLoop
void emitLoop()
-
request
public void request(long n)
- Specified by:
requestin interfaceorg.reactivestreams.Subscription
-
cancel
public void cancel()
- Specified by:
cancelin interfaceorg.reactivestreams.Subscription
-
-