Class BaseSubscriberAdapter<T,U>
java.lang.Object
software.amazon.awssdk.utils.async.DelegatingSubscriber<T,U>
software.amazon.awssdk.utils.async.BaseSubscriberAdapter<T,U>
- Type Parameters:
T- the type that the delegate subscriber demands.U- the type sent by the publisher this subscriber is subscribed to.
- All Implemented Interfaces:
org.reactivestreams.Subscriber<T>
- Direct Known Subclasses:
DelegatingBufferingSubscriber,FlatteningSubscriber
Base of subscribers that can adapt one type to another. This subscriber will receive onNext signal with the
U type,
but will need to fulfill the downstream demand of the delegate
subscriber with instance of the T type.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicLongThe amount of unfulfilled demand the downstream subscriber has opened against us.protected final AtomicBooleanA flag that is used to ensure that only one thread is handling updates to the state of this subscriber at a time.protected booleanWhether the upstream subscriber has called onComplete on us.protected final AtomicReference<Throwable>Whether the upstream subscriber has called onError on us.protected booleanWhether we have called onComplete or onNext on the downstream subscriber.protected final AtomicLongThe amount of unfulfilled demand open against the upstream subscriber.protected org.reactivestreams.SubscriptionThe subscription to the upstream subscriber.Fields inherited from class software.amazon.awssdk.utils.async.DelegatingSubscriber
subscriber -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseSubscriberAdapter(org.reactivestreams.Subscriber<? super U> subscriber) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidThis method is called when demand from the downstream subscriber needs to be fulfilled.protected voidThis is invoked after each downstream request or upstream onNext, onError or onComplete.voidvoidvoidvoidonSubscribe(org.reactivestreams.Subscription subscription)
-
Field Details
-
upstreamDemand
The amount of unfulfilled demand open against the upstream subscriber. -
downstreamDemand
The amount of unfulfilled demand the downstream subscriber has opened against us. -
handlingStateUpdate
A flag that is used to ensure that only one thread is handling updates to the state of this subscriber at a time. This allows us to ensure that the downstream onNext, onComplete and onError are only ever invoked serially. -
onErrorFromUpstream
Whether the upstream subscriber has called onError on us. If this is null, we haven't gotten an onError. If it's non-null this will be the exception that the upstream passed to our onError. After we get an onError, we'll call onError on the downstream subscriber as soon as possible. -
terminalCallMadeDownstream
protected volatile boolean terminalCallMadeDownstreamWhether we have called onComplete or onNext on the downstream subscriber. -
onCompleteCalledByUpstream
protected volatile boolean onCompleteCalledByUpstreamWhether the upstream subscriber has called onComplete on us. After this happens, we'll drain any outstanding items in the allItems queue and then call onComplete on the downstream subscriber. -
upstreamSubscription
protected org.reactivestreams.Subscription upstreamSubscriptionThe subscription to the upstream subscriber.
-
-
Constructor Details
-
BaseSubscriberAdapter
-
-
Method Details
-
fulfillDownstreamDemand
protected abstract void fulfillDownstreamDemand()This method is called when demand from the downstream subscriber needs to be fulfilled. Called in a loop untildownstreamDemandis no longer needed. Implementations are responsible for decrementing thedownstreamDemandaccordingly as demand gets fulfilled. -
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription subscription) - Specified by:
onSubscribein interfaceorg.reactivestreams.Subscriber<T>- Overrides:
onSubscribein classDelegatingSubscriber<T,U>
-
onNext
-
onError
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<T>- Overrides:
onErrorin classDelegatingSubscriber<T,U>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<T>- Overrides:
onCompletein classDelegatingSubscriber<T,U>
-
handleStateUpdate
protected void handleStateUpdate()This is invoked after each downstream request or upstream onNext, onError or onComplete.
-