Class AsyncIterablePublisher.SubscriptionImpl
- java.lang.Object
-
- org.reactivestreams.example.unicast.AsyncIterablePublisher.SubscriptionImpl
-
- All Implemented Interfaces:
java.lang.Runnable
,Subscription
- Enclosing class:
- AsyncIterablePublisher<T>
final class AsyncIterablePublisher.SubscriptionImpl extends java.lang.Object implements Subscription, java.lang.Runnable
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
cancelled
private long
demand
private java.util.concurrent.ConcurrentLinkedQueue<AsyncIterablePublisher.Signal>
inboundSignals
private java.util.Iterator<T>
iterator
private java.util.concurrent.atomic.AtomicBoolean
on
(package private) Subscriber<? super T>
subscriber
-
Constructor Summary
Constructors Constructor Description SubscriptionImpl(Subscriber<? super T> subscriber)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Request thePublisher
to stop sending data and clean up resources.private void
doCancel()
private void
doRequest(long n)
private void
doSend()
private void
doSubscribe()
(package private) void
init()
void
request(long n)
No events will be sent by aPublisher
until demand is signaled via this method.void
run()
private void
signal(AsyncIterablePublisher.Signal signal)
private void
terminateDueTo(java.lang.Throwable t)
private void
tryScheduleToExecute()
-
-
-
Field Detail
-
subscriber
final Subscriber<? super T> subscriber
-
cancelled
private boolean cancelled
-
demand
private long demand
-
iterator
private java.util.Iterator<T> iterator
-
inboundSignals
private final java.util.concurrent.ConcurrentLinkedQueue<AsyncIterablePublisher.Signal> inboundSignals
-
on
private final java.util.concurrent.atomic.AtomicBoolean on
-
-
Constructor Detail
-
SubscriptionImpl
SubscriptionImpl(Subscriber<? super T> subscriber)
-
-
Method Detail
-
doRequest
private void doRequest(long n)
-
doCancel
private void doCancel()
-
doSubscribe
private void doSubscribe()
-
doSend
private void doSend()
-
terminateDueTo
private void terminateDueTo(java.lang.Throwable t)
-
signal
private void signal(AsyncIterablePublisher.Signal signal)
-
run
public final void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
tryScheduleToExecute
private final void tryScheduleToExecute()
-
request
public void request(long n)
Description copied from interface:Subscription
No events will be sent by aPublisher
until 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
Publisher
as "effectively unbounded".Whatever has been requested can be sent by the
Publisher
so only signal demand for what can be safely handled.A
Publisher
can send less than is requested if the stream ends but then must emit eitherSubscriber.onError(Throwable)
orSubscriber.onComplete()
.- Specified by:
request
in interfaceSubscription
- Parameters:
n
- the strictly positive number of elements to requests to the upstreamPublisher
-
cancel
public void cancel()
Description copied from interface:Subscription
Request thePublisher
to stop sending data and clean up resources.Data may still be sent to meet previously signalled demand after calling cancel.
- Specified by:
cancel
in interfaceSubscription
-
init
void init()
-
-