def flush(max = nil)
      if ! @seekable
        toWrite = @buffer.length
        toWrite = max if max && max < @buffer.length
        numWritten = 0
        while toWrite > 0
          numWritten = @io.write_nonblock(@buffer[0,toWrite])
          raise Errno::EAGAIN if numWritten == 0
          @buffer = @buffer[numWritten,@buffer.length]
          toWrite -= numWritten
        end
      else
        while @buffer.length > 0
          @io.seek @buffer.first[0], IO::SEEK_SET
          while @buffer.first[1].length > 0
            numWritten = @io.write_nonblock(@buffer.first[1])
            raise Errno::EAGAIN if numWritten == 0
            @buffer.first[1] = @buffer.first[1][numWritten,@buffer.first[1].length]
          end
          # This chunk has been fully written. Remove it
          @buffer.shift
        end
      end
    end
def flush(max = nil)
      if ! @seekable
        toWrite = @buffer.length
        toWrite = max if max && max < @buffer.length
        numWritten = 0
        while toWrite > 0
          numWritten = @io.write_nonblock(@buffer[0,toWrite])
          raise Errno::EAGAIN if numWritten == 0
          @buffer = @buffer[numWritten,@buffer.length]
          toWrite -= numWritten
        end
      else
        while @buffer.length > 0
          @io.seek @buffer.first[0], IO::SEEK_SET
          while @buffer.first[1].length > 0
            numWritten = @io.write_nonblock(@buffer.first[1])
            raise Errno::EAGAIN if numWritten == 0
            @buffer.first[1] = @buffer.first[1][numWritten,@buffer.first[1].length]
          end
          # This chunk has been fully written. Remove it
          @buffer.shift
        end
      end
    end
Write the contents of the output buffer to the io. This method throws all of the exceptions that write would throw
 (EAGAIN, EWOULDBLOCK, etc)
 If max is specified and this is a non-seekable io, at most that many bytes are written.