/** * Read and publish data one at a time until there is no more data, no more * demand, or perhaps we completed in the mean time. * @return {@code true} if there is more demand; {@code false} if there is * no more demand or we have completed. */ private boolean readAndPublish() throws IOException { long r; while ((r = this.demand) > 0 && !this.state.get().equals(State.COMPLETED)) { T data = read(); if (data != null) { if (r != Long.MAX_VALUE) { DEMAND_FIELD_UPDATER.addAndGet(this, -1L); } Subscriber<? super T> subscriber = this.subscriber; Assert.state(subscriber != null, "No subscriber"); if (rsReadLogger.isTraceEnabled()) { rsReadLogger.trace(getLogPrefix() + "Publishing data read"); } subscriber.onNext(data); } else { if (rsReadLogger.isTraceEnabled()) { rsReadLogger.trace(getLogPrefix() + "No more data to read"); } return true; } } return false; }
/** * Read and publish data one at a time until there is no more data, no more * demand, or perhaps we completed in the mean time. * @return {@code true} if there is more demand; {@code false} if there is * no more demand or we have completed. */ private boolean readAndPublish() throws IOException { long r; while ((r = this.demand) > 0 && !this.state.get().equals(State.COMPLETED)) { T data = read(); if (data != null) { if (r != Long.MAX_VALUE) { DEMAND_FIELD_UPDATER.addAndGet(this, -1L); } Subscriber<? super T> subscriber = this.subscriber; Assert.state(subscriber != null, "No subscriber"); if (rsReadLogger.isTraceEnabled()) { rsReadLogger.trace(getLogPrefix() + "Publishing data read"); } subscriber.onNext(data); } else { if (rsReadLogger.isTraceEnabled()) { rsReadLogger.trace(getLogPrefix() + "No more data to read"); } return true; } } return false; }
/** * Read and publish data one at a time until there is no more data, no more * demand, or perhaps we completed in the mean time. * @return {@code true} if there is more demand; {@code false} if there is * no more demand or we have completed. */ private boolean readAndPublish() throws IOException { long r; while ((r = this.demand) > 0 && !this.state.get().equals(State.COMPLETED)) { T data = read(); if (data != null) { if (r != Long.MAX_VALUE) { DEMAND_FIELD_UPDATER.addAndGet(this, -1L); } Subscriber<? super T> subscriber = this.subscriber; Assert.state(subscriber != null, "No subscriber"); if (logger.isTraceEnabled()) { logger.trace("Data item read, publishing.."); } subscriber.onNext(data); } else { if (logger.isTraceEnabled()) { logger.trace("No more data to read"); } return true; } } return false; }
/** * Read and publish data one at a time until there is no more data, no more * demand, or perhaps we completed in the mean time. * @return {@code true} if there is more demand; {@code false} if there is * no more demand or we have completed. */ private boolean readAndPublish() throws IOException { long r; while ((r = this.demand) > 0 && !this.state.get().equals(State.COMPLETED)) { T data = read(); if (data != null) { if (r != Long.MAX_VALUE) { DEMAND_FIELD_UPDATER.addAndGet(this, -1L); } Subscriber<? super T> subscriber = this.subscriber; Assert.state(subscriber != null, "No subscriber"); if (rsReadLogger.isTraceEnabled()) { rsReadLogger.trace(getLogPrefix() + "Publishing data read"); } subscriber.onNext(data); } else { if (rsReadLogger.isTraceEnabled()) { rsReadLogger.trace(getLogPrefix() + "No more data to read"); } return true; } } return false; }