code: @NotNull
  	@Override
  	public Promise<Void> write(@Nullable ByteBuf buf) {
  		assert eventloop.inEventloopThread();
  		checkState(!writeEndOfStream, "End of stream has already been sent");
  		if (channel == null) {
  			if (buf != null) buf.recycle();
  			return Promise.ofException(CLOSE_EXCEPTION);
  		}
  		writeEndOfStream |= buf == null;
  		if (write != null) return write;
  
  		if (writeBuf == null) {
  			writeBuf = buf;
  		} else {
  			if (buf != null) {
  				writeBuf = ByteBufPool.ensureWriteRemaining(this.writeBuf, buf.readRemaining());
  				writeBuf.put(buf.array(), buf.head(), buf.readRemaining());
  				buf.recycle();
  			}
  		}
  
  		try {
  			doWrite();
  		} catch (IOException e) {
  			close(e);
  			return Promise.ofException(e);
  		}
  
  		if (this.writeBuf == null) {
  			return Promise.complete();
  		}
  		write = new SettablePromise<>();
  		if (writeTimeout != NO_TIMEOUT) {
  			scheduleWriteTimeout();
  		}
  		updateInterests();
  		return write;
  	}
docs: write cycle