class ActionController::Live::Buffer

:nodoc:

def abort

See also #close.

anything that's being written.
disconnected; the reading thread is no longer interested in
Inform the producer/writing thread that the client has
def abort
  synchronize do
    @aborted = true
    @buf.clear
  end
end

def build_queue(queue_size)

def build_queue(queue_size)
  queue_size ? SizedQueue.new(queue_size) : Queue.new
end

def call_on_error

def call_on_error
  @error_callback.call
end

def close

See also #abort.

uses this to notify us that it's finished supplying content.
Write a 'close' event to the buffer; the producer/writing thread
def close
  synchronize do
    super
    @buf.push nil
    @cv.broadcast
  end
end

def connected?

by `ignore_disconnect`.
The result of calling `write` when this is `false` is determined

Is the client still connected and waiting for content?
def connected?
  !@aborted
end

def each_chunk(&block)

def each_chunk(&block)
  loop do
    str = nil
    ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
      str = @buf.pop
    end
    break unless str
    yield str
  end
end

def initialize(response)

def initialize(response)
  super(response, build_queue(self.class.queue_size))
  @error_callback = lambda { true }
  @cv = new_cond
  @aborted = false
  @ignore_disconnect = false
end

def on_error(&block)

def on_error(&block)
  @error_callback = block
end

def write(string)

def write(string)
  unless @response.committed?
    @response.headers["Cache-Control"] ||= "no-cache"
    @response.delete_header "Content-Length"
  end
  super
  unless connected?
    @buf.clear
    unless @ignore_disconnect
      # Raise ClientDisconnected, which is a RuntimeError (not an
      # IOError), because that's more appropriate for something beyond
      # the developer's control.
      raise ClientDisconnected, "client disconnected"
    end
  end
end

def writeln(string)

Same as +write+ but automatically include a newline at the end of the string.
def writeln(string)
  write string.end_with?("\n") ? string : "#{string}\n"
end