final IoWriteFutureImpl future = new IoWriteFutureImpl(buffer);
if (isClosing()) {
future.setValue(new IOException("Closed"));
} else {
if (!pendingWrite.compareAndSet(null, future)) {
throw new WritePendingException();
}
doWriteIfPossible(false);
}
return future;
}