class ActionController::Live::Buffer

:nodoc:

def await_close

def await_close
  synchronize do
    @cv.wait_until { @closed }
  end
end

def call_on_error

def call_on_error
  @error_callback.call
end

def close

def close
  synchronize do
    super
    @buf.push nil
    @cv.broadcast
  end
end

def each

def each
  @response.sending!
  while str = @buf.pop
    yield str
  end
  @response.sent!
end

def initialize(response)

def initialize(response)
  @error_callback = lambda { true }
  @cv = new_cond
  super(response, SizedQueue.new(10))
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.headers.delete "Content-Length"
  end
  super
end