@Override public int write(ByteBuffer[] outputBuffers, Callback callback) throws IOException { int ret = 0; CountingCallback countingCallback = new CountingCallback(callback, outputBuffers.length); for (ByteBuffer outputBuffer : outputBuffers) { ret += write(outputBuffer, countingCallback); } return ret; }
@Override public int write(ByteBuffer[] outputBuffers, Callback callback) throws IOException { int ret = 0; CountingCallback countingCallback = new CountingCallback(callback, outputBuffers.length); for (ByteBuffer outputBuffer : outputBuffers) { ret += write(outputBuffer, countingCallback); } return ret; }
@Override public void sendFrames(List<Frame> frames, Callback callback) { CountingCallback countingCallback = new CountingCallback(callback, frames.size()); frames.forEach(frame -> sendFrame(frame, countingCallback)); }
public int write(ByteBuffer[] outputBuffers, Callback callback) throws Throwable { int ret = 0; CountingCallback countingCallback = new CountingCallback(callback, outputBuffers.length); for(ByteBuffer outputBuffer : outputBuffers) { ret += write(outputBuffer, countingCallback); } return ret; }
@Override public void sendFrames(List<Frame> frames, Callback callback) { CountingCallback countingCallback = new CountingCallback(callback, frames.size()); frames.forEach(frame -> sendFrame(frame, countingCallback)); }
public static long transferTo(FileChannel fileChannel, long len, Callback callback, BufferReaderHandler handler) throws IOException { long bufferSize = Math.min(FILE_READER_BUFFER_SIZE, len); long count = 0; long bufferCount = (len + bufferSize - 1) / bufferSize; CountingCallback countingCallback = new CountingCallback(callback, (int) bufferCount); try (FileChannel fc = fileChannel) { ByteBuffer buf = ByteBuffer.allocate((int) bufferSize); int i; while ((i = fc.read(buf)) != -1) { if (i > 0) { count += i; buf.flip(); handler.readBuffer(buf, countingCallback, count); } if (count >= len) { break; } else { buf = ByteBuffer.allocate((int) bufferSize); } } } return count; }
public static long transferTo(FileChannel fileChannel, long len, Callback callback, BufferReaderHandler handler) throws IOException { long bufferSize = Math.min(FILE_READER_BUFFER_SIZE, len); long count = 0; long bufferCount = (len + bufferSize - 1) / bufferSize; CountingCallback countingCallback = new CountingCallback(callback, (int) bufferCount); try (FileChannel fc = fileChannel) { ByteBuffer buf = ByteBuffer.allocate((int) bufferSize); int i = 0; while ((i = fc.read(buf)) != -1) { if (i > 0) { count += i; buf.flip(); handler.readBuffer(buf, countingCallback, count); } if (count >= len) { break; } else { buf = ByteBuffer.allocate((int) bufferSize); } } } return count; }
public static long transferTo(FileChannel fileChannel, long len, Callback callback, BufferReaderHandler handler) throws IOException { long bufferSize = Math.min(FILE_READER_BUFFER_SIZE, len); long count = 0; long bufferCount = (len + bufferSize - 1) / bufferSize; CountingCallback countingCallback = new CountingCallback(callback, (int) bufferCount); try (FileChannel fc = fileChannel) { ByteBuffer buf = ByteBuffer.allocate((int) bufferSize); int i; while ((i = fc.read(buf)) != -1) { if (i > 0) { count += i; buf.flip(); handler.readBuffer(buf, countingCallback, count); } if (count >= len) { break; } else { buf = ByteBuffer.allocate((int) bufferSize); } } } return count; }
public static long transferTo(FileChannel fileChannel, long pos, long len, Callback callback, BufferReaderHandler handler) throws IOException { long bufferSize = Math.min(FILE_READER_BUFFER_SIZE, len); long count = 0; long bufferCount = (len + bufferSize - 1) / bufferSize; CountingCallback countingCallback = new CountingCallback(callback, (int) bufferCount); try (FileChannel fc = fileChannel) { ByteBuffer buf = ByteBuffer.allocate((int) bufferSize); int i; while ((i = fc.read(buf, pos)) != -1) { if (i > 0) { count += i; pos += i; buf.flip(); handler.readBuffer(buf, countingCallback, count); } if (count >= len) { break; } else { buf = ByteBuffer.allocate((int) Math.min(FILE_READER_BUFFER_SIZE, len - count)); } } } return count; } }
public static long transferTo(FileChannel fileChannel, long pos, long len, Callback callback, BufferReaderHandler handler) throws IOException { long bufferSize = Math.min(FILE_READER_BUFFER_SIZE, len); long count = 0; long bufferCount = (len + bufferSize - 1) / bufferSize; CountingCallback countingCallback = new CountingCallback(callback, (int) bufferCount); try (FileChannel fc = fileChannel) { ByteBuffer buf = ByteBuffer.allocate((int) bufferSize); int i = 0; while ((i = fc.read(buf, pos)) != -1) { if (i > 0) { count += i; pos += i; buf.flip(); handler.readBuffer(buf, countingCallback, count); } if (count >= len) { break; } else { buf = ByteBuffer.allocate((int) Math.min(FILE_READER_BUFFER_SIZE, len - count)); } } } return count; } }
public static long transferTo(FileChannel fileChannel, long pos, long len, Callback callback, BufferReaderHandler handler) throws IOException { long bufferSize = Math.min(FILE_READER_BUFFER_SIZE, len); long count = 0; long bufferCount = (len + bufferSize - 1) / bufferSize; CountingCallback countingCallback = new CountingCallback(callback, (int) bufferCount); try (FileChannel fc = fileChannel) { ByteBuffer buf = ByteBuffer.allocate((int) bufferSize); int i; while ((i = fc.read(buf, pos)) != -1) { if (i > 0) { count += i; pos += i; buf.flip(); handler.readBuffer(buf, countingCallback, count); } if (count >= len) { break; } else { buf = ByteBuffer.allocate((int) Math.min(FILE_READER_BUFFER_SIZE, len - count)); } } } return count; } }
@Override public void frames(StreamSPI stream, Callback callback, Frame frame, Frame... frames) { // We want to generate as late as possible to allow re-prioritization; // generation will happen while processing the entries. // The callback needs to be notified only when the last frame completes. int length = frames.length; if (length == 0) { frame(new ControlEntry(frame, stream, callback), true); } else { callback = new CountingCallback(callback, 1 + length); frame(new ControlEntry(frame, stream, callback), false); for (int i = 1; i <= length; ++i) frame(new ControlEntry(frames[i - 1], stream, callback), i == length); } }
@Override public void frames(StreamSPI stream, Callback callback, Frame frame, Frame... frames) { // We want to generate as late as possible to allow re-prioritization; // generation will happen while processing the entries. // The callback needs to be notified only when the last frame completes. int length = frames.length; if (length == 0) { frame(new ControlEntry(frame, stream, callback), true); } else { callback = new CountingCallback(callback, 1 + length); frame(new ControlEntry(frame, stream, callback), false); for (int i = 1; i <= length; ++i) frame(new ControlEntry(frames[i - 1], stream, callback), i == length); } }