125126127128129130131132133
*/ public IoFuture<Void, Void> write(ByteBuffer src, CompletionHandler<Void, Void> handler) { if (!writePending.compareAndSet(false, true)) { throw new WritePendingException(); } return new Writer(handler, src).start(); }
127128129130131132133134135
326327328329330331332333334335336
{ if (DEBUG) LOG.debug("write: {} {}", this, BufferUtil.toDetailString(buffers)); if (!updateState(__IDLE,__WRITING)) throw new WritePendingException(); try { boolean flushed=_endPoint.flush(buffers); if (DEBUG)
173174175176177178179180181182183
{ case CLOSED: break loop; case UNREADY: throw new WritePendingException(); // TODO ? default: if (_state.compareAndSet(state,OutputState.CLOSED)) { try
230231232233234235236237238239240
new AsyncFlush().iterate(); return; case PENDING: case UNREADY: throw new WritePendingException(); case CLOSED: return; } break;
290291292293294295296297298299300
new AsyncWrite(b,off,len,complete).iterate(); return; case PENDING: case UNREADY: throw new WritePendingException(); case CLOSED: throw new EofException("Closed"); } break;
388389390391392393394395396397398
new AsyncWrite(buffer,complete).iterate(); return; case PENDING: case UNREADY: throw new WritePendingException(); case CLOSED: throw new EofException("Closed"); } break;
465466467468469470471472473474475
new AsyncFlush().iterate(); return; case PENDING: case UNREADY: throw new WritePendingException(); case CLOSED: throw new EofException("Closed"); } break;
214215216217218219220221222223224
} protected void data(byte[] bytes, int offset, int length, Callback callback) { if (state != WriteState.IDLE) throw new WritePendingException(); this.state = WriteState.READY; this.buffer = bytes; this.offset = offset; this.length = length; this.callback = callback;
485486487488489490491492
} if (isClosed()) callback.failed(new EofException()); else callback.failed(new WritePendingException()); return false; }