@Override public void awaitWritable(final long time, final TimeUnit timeUnit) throws IOException { responseChannel.awaitWritable(time, timeUnit); } };
public void awaitWritable() throws IOException { sink.awaitWritable(); }
public void awaitWritable(final long time, final TimeUnit timeUnit) throws IOException { sink.awaitWritable(time, timeUnit); }
public void awaitWritable() throws IOException { channel.awaitWritable(); }
@Override public void awaitWritable() throws IOException { responseChannel.awaitWritable(); }
public void awaitWritable(final long time, final TimeUnit timeUnit) throws IOException { channel.awaitWritable(time, timeUnit); }
public void awaitWritable(final long time, final TimeUnit timeUnit) throws IOException { delegate.awaitWritable(time, timeUnit); }
public void awaitWritable(final long time, final TimeUnit timeUnit) throws IOException { delegate.awaitWritable(time, timeUnit); }
public void awaitWritable() throws IOException { delegate.awaitWritable(); }
public void awaitWritable() throws IOException { delegate.awaitWritable(); }
/** * Transfer bytes between two channels efficiently, blocking if necessary. * * @param destination the destination channel * @param source the source file channel * @param startPosition the start position in the source file * @param count the number of bytes to transfer * @throws IOException if an I/O error occurs */ public static void transferBlocking(StreamSinkChannel destination, FileChannel source, long startPosition, final long count) throws IOException { long remaining = count; long res; while (remaining > 0L) { while ((res = destination.transferFrom(source, startPosition, remaining)) == 0L) { try { destination.awaitWritable(); } catch (InterruptedIOException e) { final long bytes = count - remaining; if (bytes > (long) Integer.MAX_VALUE) { e.bytesTransferred = -1; } else { e.bytesTransferred = (int) bytes; } } } remaining -= res; startPosition += res; } }
@Override public void awaitWritable(final long time, final TimeUnit timeUnit) throws IOException { if (isFinished()) { throw UndertowMessages.MESSAGES.channelIsClosed(); } delegate.awaitWritable(time, timeUnit); }
/** {@inheritDoc} */ public void flush() throws IOException { final StreamSinkChannel delegate = this.delegate; if (! delegate.flush()) { long start = System.nanoTime(); long elapsed = 0L, writeTimeout; do { writeTimeout = this.writeTimeout; if (writeTimeout == 0L || writeTimeout == Long.MAX_VALUE) { delegate.awaitWritable(); } else if (writeTimeout <= elapsed) { throw msg.writeTimeout(); } else { delegate.awaitWritable(writeTimeout - elapsed, TimeUnit.NANOSECONDS); } elapsed = System.nanoTime() - start; } while (! delegate.flush()); } }
/** {@inheritDoc} */ public void flush() throws IOException { final StreamSinkChannel delegate = this.delegate; if (! delegate.flush()) { long start = System.nanoTime(); long elapsed = 0L, writeTimeout; do { writeTimeout = this.writeTimeout; if (writeTimeout == 0L || writeTimeout == Long.MAX_VALUE) { delegate.awaitWritable(); } else if (writeTimeout <= elapsed) { throw msg.writeTimeout(); } else { delegate.awaitWritable(writeTimeout - elapsed, TimeUnit.NANOSECONDS); } elapsed = System.nanoTime() - start; } while (! delegate.flush()); } }
@Override public void awaitWritable() throws IOException { if (isFinished()) { throw UndertowMessages.MESSAGES.channelIsClosed(); } delegate.awaitWritable(); }
private void writeBufferBlocking(final boolean writeFinal) throws IOException { if (channel == null) { channel = exchange.getResponseChannel(); } buffer.flip(); while (buffer.hasRemaining()) { if(writeFinal) { channel.writeFinal(buffer); } else { channel.write(buffer); } if(buffer.hasRemaining()) { channel.awaitWritable(); } } buffer.clear(); state |= FLAG_WRITE_STARTED; }
/** * Perform a blocking write operation. * * @param src the source buffer * @return the number of bytes actually written (will be greater than zero) * @throws IOException if an I/O error occurs */ public int write(final ByteBuffer src) throws IOException { if (! src.hasRemaining()) { return 0; } final StreamSinkChannel delegate = this.delegate; int res; if ((res = delegate.write(src)) == 0L) { long start = System.nanoTime(); long elapsed = 0L, writeTimeout; do { writeTimeout = this.writeTimeout; if (writeTimeout == 0L || writeTimeout == Long.MAX_VALUE) { delegate.awaitWritable(); } else if (writeTimeout <= elapsed) { throw msg.writeTimeout(); } else { delegate.awaitWritable(writeTimeout - elapsed, TimeUnit.NANOSECONDS); } elapsed = System.nanoTime() - start; } while ((res = delegate.write(src)) == 0L); } return res; }
writeTimeout = this.writeTimeout; if (writeTimeout == 0L || writeTimeout == Long.MAX_VALUE) { delegate.awaitWritable(); } else if (writeTimeout <= elapsed) { throw msg.writeTimeout(); } else { delegate.awaitWritable(writeTimeout - elapsed, TimeUnit.NANOSECONDS);
/** {@inheritDoc} */ public void flush() throws IOException { final boolean closed = enter(); try { final StreamSinkChannel channel = this.channel; if (! channel.flush()) { long timeout; long start = System.nanoTime(); long elapsed = 0L; do { timeout = this.timeout; if (timeout == 0L) { channel.awaitWritable(); } else if (timeout < elapsed) { throw msg.writeTimeout(); } else { channel.awaitWritable(timeout - elapsed, TimeUnit.NANOSECONDS); } elapsed = System.nanoTime() - start; } while (! channel.flush()); } } finally { exit(closed); } }
/** {@inheritDoc} */ public void close() throws IOException { final boolean closed = enter(); try { if (closed) return; final StreamSinkChannel channel = this.channel; channel.shutdownWrites(); if (! channel.flush()) { long timeout; long start = System.nanoTime(); long elapsed = 0L; do { timeout = this.timeout; if (timeout == 0L) { channel.awaitWritable(); } else if (timeout < elapsed) { throw msg.writeTimeout(); } else { channel.awaitWritable(timeout - elapsed, TimeUnit.NANOSECONDS); } elapsed = System.nanoTime() - start; } while (! channel.flush()); } } finally { exit(true); } } }