lib/async/http/body/writable.rb in async-http-0.26.0 vs lib/async/http/body/writable.rb in async-http-0.27.0

- old
+ new

@@ -34,17 +34,18 @@ @finished = false @stopped = nil end + # Has the producer called #finish and has the reader consumed the nil token? def empty? @finished end # Read the next available chunk. def read - # I'm not sure if this is a good idea (*). + # I'm not sure if this is a good idea. # if @stopped # raise @stopped # end return if @finished @@ -54,13 +55,13 @@ end return chunk end - # Cause the next call to write to fail with the given error. + # Stop generating output; cause the next call to write to fail with the given error. def stop(error) - @stopped = error + @stopped ||= error end # Write a single chunk to the body. Signal completion by calling `#finish`. def write(chunk) # If the reader breaks, the writer will break. @@ -75,10 +76,10 @@ @queue.enqueue(chunk) end alias << write - # Signal that output has finished. + # Signal that output has finished. This must be called at least once. def finish @queue.enqueue(nil) end def inspect