long requested() { return current.requested(); }
@Override public long requested() { return emitter.requested(); }
@Override public long requested() { return emitter.requested(); }
/** * Method to check if XML iteration can be still performed. * <p> * Checks if {@link Flowable} is still valid based on: * <ul> * <li>Downstream is actively requesting further elements.</li> * <li>XML document end has not reached.</li> * </ul> * * @param emitter The emitter to currently handling events. * @param eventType XML document event type. * @return {@code true} if Flowable emission is valid. */ private boolean isFlowableEmissionValid(FlowableEmitter<SimpleSuggestionItem> emitter, int eventType) { return eventType != END_DOCUMENT && !emitter.isCancelled() && emitter.requested() > 0; }
@Override public void subscribe(FlowableEmitter<String> e) throws Exception { Log.d(TAG, index + "使用token=" + token + "发起请求" + ",request=" + e.requested()); //模拟根据Token去请求信息的过程。 long tokeTime = Long.valueOf(token); if (System.currentTimeMillis() - tokeTime < 2000) { e.onNext(index + ":" + token + "的用户信息"); } else { e.onError(new Throwable(ERROR_TOKEN)); } } }, BackpressureStrategy.ERROR);