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

def read_in_background(task: Task.current)

def read_in_background(task: Task.current)
	task.async do |nested_task|
		nested_task.annotate("#{version} reading data")
		
		begin
			# Even thought the connection might be logically closed, we are not done until all HTTP/2 streams are closed or the underlying I/O is closed.
			while !@stream.closed?
				self.read_frame
			end
		rescue
			Async.logger.debug(self) {$!}
		ensure
			stop_connection
		end
	end
end