@Override public void request(long n) { requested.increment(n, t -> tryComplete(t)); tryPublish(); }
if (!subscriber.isClosed() && requested.get() > 0 && publishing.compareAndSet(false, true)) { try { Flow.Subscriber<? super DataChunk> sub = this.subscriber.get(); // blocking retrieval while (!subscriber.isClosed() && requested.tryDecrement()) { if (!publishSingleOrFinish(sub)) { requested.increment(1, this::tryComplete); break; if (!subscriber.isClosed() && requested.get() > 0) { long nextDelay = retrySchema.nextDelay(retryCounter.getAndIncrement(), lastRetryDelay); lastRetryDelay = nextDelay;
private void publish(byte[] buffer, int offset, int length) throws IOException { Objects.requireNonNull(buffer); try { final Flow.Subscriber<? super ByteBuffer> sub = subscriber.get(); while (!subscriber.isClosed() && !requested.tryDecrement()) { Thread.sleep(250); // wait until some data can be sent or the stream has been closed } synchronized (invocationLock) { if (subscriber.isClosed()) { throw new IOException("Output stream already closed."); } sub.onNext(ByteBuffer.wrap(buffer, offset, length)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); complete(e); throw new IOException(e); } catch (ExecutionException e) { complete(e.getCause()); throw new IOException(e.getCause()); } }
if (!subscriber.isClosed() && requested.get() > 0 && publishing.compareAndSet(false, true)) { try { Flow.Subscriber<? super DataChunk> sub = this.subscriber.get(); // blocking retrieval while (!subscriber.isClosed() && requested.tryDecrement()) { if (!publishSingleOrFinish(sub)) { requested.increment(1, this::tryComplete); break; if (!subscriber.isClosed() && requested.get() > 0) { long nextDelay = retrySchema.nextDelay(retryCounter.getAndIncrement(), lastRetryDelay); lastRetryDelay = nextDelay;
private void publish(byte[] buffer, int offset, int length) throws IOException { Objects.requireNonNull(buffer); try { final Flow.Subscriber<? super ByteBuffer> sub = subscriber.get(); while (!subscriber.isClosed() && !requested.tryDecrement()) { Thread.sleep(250); // wait until some data can be sent or the stream has been closed } synchronized (invocationLock) { if (subscriber.isClosed()) { throw new IOException("Output stream already closed."); } sub.onNext(ByteBuffer.wrap(buffer, offset, length)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); complete(e); throw new IOException(e); } catch (ExecutionException e) { complete(e.getCause()); throw new IOException(e.getCause()); } }
@Override public void request(long n) { requested.increment(n, t -> complete(t)); }
@Override public void request(long n) { requested.increment(n, t -> tryComplete(t)); tryPublish(); }
@Override public void request(long n) { requested.increment(n, t -> complete(t)); }