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

def close(error = nil)

def close(error = nil)
	@reader = nil
	
	super
end

def concurrency

def concurrency
	self.maximum_concurrent_streams
end

def http1?

def http1?
	false
end

def http2?

def http2?
	true
end

def initialize(*)

def initialize(*)
	super
	
	@count = 0
	@reader = nil
	
	# Writing multiple frames at the same time can cause odd problems if frames are only partially written. So we use a semaphore to ensure frames are written in their entirety.
	@write_frame_guard = Async::Semaphore.new(1)
end

def peer

def peer
	@stream.io
end

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 for #{self.class}.")
		
		begin
			while !self.closed?
				self.consume_window
				self.read_frame
			end
		rescue IOError, EOFError, Errno::ECONNRESET, Errno::EPIPE, Async::Wrapper::Cancelled
			# Ignore.
		ensure
			close($!)
		end
	end
end

def reusable?

def reusable?
	!(self.closed? || @stream.closed?)
end

def start_connection

def start_connection
	@reader ||= read_in_background
end

def to_s

def to_s
	"\#<#{self.class} #{@streams.count} active streams>"
end

def version

def version
	VERSION
end

def viable?

Can we use this connection to make requests?
def viable?
	@stream.connected?
end

def write_frame(frame)

def write_frame(frame)
	# We don't want to write multiple frames at the same time.
	@write_frame_guard.acquire do
		super
	end
	
	@stream.flush
end

def write_frames(&block)

def write_frames(&block)
	@write_frame_guard.acquire do
		super
	end
	
	@stream.flush
end