@@ -72,8 +72,10 @@ public abstract class AbstractListenerReadPublisher<T> implements Publisher<T> {
72
72
@ Nullable
73
73
private volatile Subscriber <? super T > subscriber ;
74
74
75
+ /** Flag to defer transition to COMPLETED briefly while SUBSCRIBING or READING. */
75
76
private volatile boolean completionPending ;
76
77
78
+ /** Flag to defer transition to COMPLETED briefly while SUBSCRIBING or READING. */
77
79
@ Nullable
78
80
private volatile Throwable errorPending ;
79
81
@@ -123,8 +125,8 @@ public final void onDataAvailable() {
123
125
}
124
126
125
127
/**
126
- * Subclasses can call this method to delegate a container notification when
127
- * all data has been read.
128
+ * Subclasses can call this method to signal onComplete, delegating a
129
+ * notification from the container when all data has been read.
128
130
*/
129
131
public void onAllDataRead () {
130
132
State state = this .state .get ();
@@ -135,7 +137,8 @@ public void onAllDataRead() {
135
137
}
136
138
137
139
/**
138
- * Subclasses can call this to delegate container error notifications.
140
+ * Subclasses can call this to signal onError, delegating a
141
+ * notification from the container for an error.
139
142
*/
140
143
public final void onError (Throwable ex ) {
141
144
State state = this .state .get ();
@@ -183,10 +186,10 @@ public final void onError(Throwable ex) {
183
186
// Private methods for use in State...
184
187
185
188
/**
186
- * Read and publish data one at a time until there is no more data, no more
187
- * demand , or perhaps we completed meanwhile .
188
- * @return {@code true} if there is more demand; {@code false} if there is
189
- * no more demand or we have completed .
189
+ * Read and publish data one by one until there are no more items
190
+ * to read (i.e. input queue drained) , or there is no more demand .
191
+ * @return {@code true} if there is demand but no more to read, or
192
+ * {@code false} if there is more to read but lack of demand .
190
193
*/
191
194
private boolean readAndPublish () throws IOException {
192
195
long r ;
@@ -269,15 +272,15 @@ private final class ReadSubscription implements Subscription {
269
272
270
273
271
274
@ Override
272
- public final void request (long n ) {
275
+ public void request (long n ) {
273
276
if (rsReadLogger .isTraceEnabled ()) {
274
277
rsReadLogger .trace (getLogPrefix () + "request " + (n != Long .MAX_VALUE ? n : "Long.MAX_VALUE" ));
275
278
}
276
279
state .get ().request (AbstractListenerReadPublisher .this , n );
277
280
}
278
281
279
282
@ Override
280
- public final void cancel () {
283
+ public void cancel () {
281
284
State state = AbstractListenerReadPublisher .this .state .get ();
282
285
if (rsReadLogger .isTraceEnabled ()) {
283
286
rsReadLogger .trace (getLogPrefix () + "cancel [" + state + "]" );
@@ -288,7 +291,7 @@ public final void cancel() {
288
291
289
292
290
293
/**
291
- * Represents a state for the {@link Publisher} to be in .
294
+ * The states that a read {@link Publisher} transitions through .
292
295
* <p><pre>
293
296
* UNSUBSCRIBED
294
297
* |
0 commit comments