Exemplo n.º 1
0
 private void writePending() {
   //        Log.i("NIO", "Writing to buffer...");
   if (mPendingWrites != null) {
     mDataSink.write(mPendingWrites);
     if (mPendingWrites.remaining() == 0) mPendingWrites = null;
   }
   if (mPendingWrites == null && mWritable != null) mWritable.onWriteable();
 }
Exemplo n.º 2
0
  @Override
  public void write(ByteBufferList bb) {
    if (mPendingWrites == null) mDataSink.write(bb);
    //        else
    //            Assert.assertTrue(mPendingWrites.remaining() <= mMaxBuffer);

    if (bb.remaining() > 0) {
      int toRead = Math.min(bb.remaining(), mMaxBuffer);
      if (toRead > 0) {
        if (mPendingWrites == null) mPendingWrites = new ByteBufferList();
        mPendingWrites.add(bb.get(toRead));
      }
    }
  }