module Async::HTTP::Protocol::HTTP2::Connection

def read_in_background(parent: Task.current)

def read_in_background(parent: Task.current)
	parent.async do |task|
		task.annotate("#{version} reading data for #{self.class}.")
		
		begin
			while !self.closed?
				self.consume_window
				self.read_frame
			end
		rescue SocketError, IOError, EOFError, Errno::ECONNRESET, Errno::EPIPE, Async::Wrapper::Cancelled
			# Ignore.
		ensure
			# Don't call #close twice.
			if @reader
				self.close($!)
			end
		end
	end
end