Class AsyncIterablePublisher.SubscriptionImpl
java.lang.Object
org.reactivestreams.example.unicast.AsyncIterablePublisher.SubscriptionImpl
- All Implemented Interfaces:
Runnable, Subscription
- Enclosing class:
AsyncIterablePublisher<T>
final class AsyncIterablePublisher.SubscriptionImpl
extends Object
implements Subscription, Runnable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate longprivate final ConcurrentLinkedQueue<AsyncIterablePublisher.Signal> private final AtomicBoolean(package private) final Subscriber<? super T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Request thePublisherto stop sending data and clean up resources.private voiddoCancel()private voiddoRequest(long n) private voiddoSend()private void(package private) voidinit()voidrequest(long n) No events will be sent by aPublisheruntil demand is signaled via this method.final voidrun()private voidsignal(AsyncIterablePublisher.Signal signal) private voidprivate final void
-
Field Details
-
subscriber
-
cancelled
private boolean cancelled -
demand
private long demand -
iterator
-
inboundSignals
-
on
-
-
Constructor Details
-
SubscriptionImpl
SubscriptionImpl(Subscriber<? super T> subscriber)
-
-
Method Details
-
doRequest
private void doRequest(long n) -
doCancel
private void doCancel() -
doSubscribe
private void doSubscribe() -
doSend
private void doSend() -
terminateDueTo
-
signal
-
run
-
tryScheduleToExecute
private final void tryScheduleToExecute() -
request
public void request(long n) Description copied from interface:SubscriptionNo events will be sent by aPublisheruntil demand is signaled via this method.It can be called however often and whenever needed—but if the outstanding cumulative demand ever becomes Long.MAX_VALUE or more, it may be treated by the
Publisheras "effectively unbounded".Whatever has been requested can be sent by the
Publisherso only signal demand for what can be safely handled.A
Publishercan send less than is requested if the stream ends but then must emit eitherSubscriber.onError(Throwable)orSubscriber.onComplete().- Specified by:
requestin interfaceSubscription- Parameters:
n- the strictly positive number of elements to requests to the upstreamPublisher
-
cancel
public void cancel()Description copied from interface:SubscriptionRequest thePublisherto stop sending data and clean up resources.Data may still be sent to meet previously signalled demand after calling cancel.
- Specified by:
cancelin interfaceSubscription
-
init
void init()
-