public void awaitReadable(final long time, final TimeUnit timeUnit) throws IOException { final StreamSourceChannel channel = this.channel; if (channel != null) { channel.awaitReadable(time, timeUnit); } }
public void awaitReadable() throws IOException { final StreamSourceChannel channel = this.channel; if (channel != null) { channel.awaitReadable(); } }
@Override public void awaitReadable() throws IOException { channel.awaitReadable(); }
@Override public void awaitReadable(long time, TimeUnit timeUnit) throws IOException { channel.awaitReadable(time, timeUnit); }
public void awaitReadable(final long time, final TimeUnit timeUnit) throws IOException { channel.awaitReadable(time, timeUnit); }
public void awaitReadable() throws IOException { source.awaitReadable(); }
public void awaitReadable(final long time, final TimeUnit timeUnit) throws IOException { source.awaitReadable(time, timeUnit); }
public void awaitReadable() throws IOException { channel.awaitReadable(); }
public void awaitReadable() throws IOException { delegate.awaitReadable(); }
public void awaitReadable(final long time, final TimeUnit timeUnit) throws IOException { delegate.awaitReadable(time, timeUnit); }
public void awaitReadable() throws IOException { if (isFinished()) { return; } delegate.awaitReadable(); }
public void awaitReadable() throws IOException { if (anyAreSet(state, FLAG_CLOSED | FLAG_FINISHED)) { return; } delegate.awaitReadable(); }
public void awaitReadable(final long time, final TimeUnit timeUnit) throws IOException { if (anyAreSet(state, FLAG_CLOSED | FLAG_FINISHED)) { return; } delegate.awaitReadable(time, timeUnit); }
/** * Transfer bytes between two channels efficiently, blocking if necessary. * * @param destination the destination file channel * @param source the source channel * @param startPosition the start position in the destination file * @param count the number of bytes to transfer * @throws IOException if an I/O error occurs */ public static void transferBlocking(FileChannel destination, StreamSourceChannel source, long startPosition, final long count) throws IOException { long remaining = count; long res; while (remaining > 0L) { while ((res = source.transferTo(startPosition, remaining, destination)) == 0L) { try { source.awaitReadable(); } 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; } }
public void awaitReadable(final long time, final TimeUnit timeUnit) throws IOException { if (isFinished()) { throw UndertowMessages.MESSAGES.channelIsClosed(); } delegate.awaitReadable(time, timeUnit); }
/** * Perform a blocking read operation. * * @param dst the destination buffer * @return the number of bytes actually read (will be greater than zero) * @throws IOException if an I/O error occurs */ public int read(final ByteBuffer dst) throws IOException { if (! dst.hasRemaining()) { return 0; } final StreamSourceChannel delegate = this.delegate; int res; if ((res = delegate.read(dst)) == 0) { long start = System.nanoTime(); long elapsed = 0L, readTimeout; do { readTimeout = this.readTimeout; if (readTimeout == 0L || readTimeout == Long.MAX_VALUE) { delegate.awaitReadable(); } else if (readTimeout <= elapsed) { throw msg.readTimeout(); } else { delegate.awaitReadable(readTimeout - elapsed, TimeUnit.NANOSECONDS); } elapsed = System.nanoTime() - start; } while ((res = delegate.read(dst)) == 0); } return res; }
/** * Perform a blocking read operation. * * @param dst the destination buffer * @return the number of bytes actually read (will be greater than zero) * @throws IOException if an I/O error occurs */ public int read(final ByteBuffer dst) throws IOException { if (! dst.hasRemaining()) { return 0; } final StreamSourceChannel delegate = this.delegate; int res; if ((res = delegate.read(dst)) == 0) { long start = System.nanoTime(); long elapsed = 0L, readTimeout; do { readTimeout = this.readTimeout; if (readTimeout == 0L || readTimeout == Long.MAX_VALUE) { delegate.awaitReadable(); } else if (readTimeout <= elapsed) { throw msg.readTimeout(); } else { delegate.awaitReadable(readTimeout - elapsed, TimeUnit.NANOSECONDS); } elapsed = System.nanoTime() - start; } while ((res = delegate.read(dst)) == 0); } return res; }
readTimeout = this.readTimeout; if (readTimeout == 0L || readTimeout == Long.MAX_VALUE) { delegate.awaitReadable(); } else if (readTimeout <= elapsed) { throw msg.readTimeout(); } else { delegate.awaitReadable(readTimeout - elapsed, TimeUnit.NANOSECONDS);
/** {@inheritDoc} */ public int read() throws IOException { boolean eof = enter(); try { if (eof) return -1; final byte[] array = new byte[1]; final ByteBuffer buffer = ByteBuffer.wrap(array); int res = channel.read(buffer); if (res == 0) { long timeout; long start = System.nanoTime(); long elapsed = 0L; do { timeout = this.timeout; if (timeout == 0L) { channel.awaitReadable(); } else if (timeout < elapsed) { throw msg.readTimeout(); } else { channel.awaitReadable(timeout - elapsed, TimeUnit.NANOSECONDS); } elapsed = System.nanoTime() - start; res = channel.read(buffer); } while (res == 0); } return (eof = res == -1) ? -1 : array[0] & 0xff; } finally { exit(eof); } }
@Override public FormData parseBlocking() throws IOException { final FormData existing = exchange.getAttachment(FORM_DATA); if (existing != null) { return existing; } StreamSourceChannel channel = exchange.getRequestChannel(); if (channel == null) { throw new IOException(UndertowMessages.MESSAGES.requestChannelAlreadyProvided()); } else { while (state != 4) { doParse(channel); if (state != 4) { channel.awaitReadable(); } } } return data; }