/**
   * This is executed when the flusher is to write all of the data to the underlying socket. In this
   * situation the writes are attempted in a non blocking way, if the task does not complete then
   * this will simply enqueue the writing task for OP_WRITE and leave the method. This returns true
   * if all the buffers are written.
   */
  private synchronized void execute() throws IOException {
    boolean ready = writer.flush();

    if (!ready) {
      boolean block = writer.isBlocking();

      if (!block && !closed) {
        scheduler.release();
      }
      scheduler.repeat();
    } else {
      scheduler.ready();
    }
  }