Exemple #1
0
 @Override
 public void writeBlock(Channel channel, byte[] bytes) throws IOException {
   try {
     boolean hasMore;
     int pos = 0;
     do {
       int frame =
           Math.min(transportFrameSize, bytes.length - pos); // # of bytes we send in this chunk
       hasMore = frame + pos < bytes.length;
       wb.write(ChunkHeader.pack(frame, hasMore));
       wb.write(bytes, pos, frame);
       scheduleReregister();
       pos += frame;
     } while (hasMore);
   } catch (InterruptedException e) {
     throw (InterruptedIOException) new InterruptedIOException().initCause(e);
   }
 }
Exemple #2
0
 @Override
 public void closeWrite() throws IOException {
   wb.close();
   // when wb is fully drained and written, we'll call closeW()
 }
Exemple #3
0
 /**
  * Returns true if we want to write to {@link #ww()}, namely when we have some data in {@link
  * #wb}.
  */
 boolean wantsToWrite() {
   return wb.readable() != 0;
 }
Exemple #4
0
 /**
  * Returns true if we want to read from {@link #rr()}, namely when we have more space in {@link
  * #rb}.
  */
 boolean wantsToRead() {
   return receiver != null && rb.writable() != 0;
 }