use a generic streams map for incoming streams

This commit is contained in:
Marten Seemann 2022-08-02 23:29:59 +02:00
parent bebff462c8
commit 621e9d4642
6 changed files with 58 additions and 449 deletions

View file

@ -57,8 +57,8 @@ type streamsMap struct {
mutex sync.Mutex
outgoingBidiStreams *outgoingStreamsMap[streamI]
outgoingUniStreams *outgoingStreamsMap[sendStreamI]
incomingBidiStreams *incomingBidiStreamsMap
incomingUniStreams *incomingUniStreamsMap
incomingBidiStreams *incomingStreamsMap[streamI]
incomingUniStreams *incomingStreamsMap[receiveStreamI]
reset bool
}
@ -93,7 +93,8 @@ func (m *streamsMap) initMaps() {
},
m.sender.queueControlFrame,
)
m.incomingBidiStreams = newIncomingBidiStreamsMap(
m.incomingBidiStreams = newIncomingStreamsMap(
protocol.StreamTypeBidi,
func(num protocol.StreamNum) streamI {
id := num.StreamID(protocol.StreamTypeBidi, m.perspective.Opposite())
return newStream(id, m.sender, m.newFlowController(id), m.version)
@ -109,7 +110,8 @@ func (m *streamsMap) initMaps() {
},
m.sender.queueControlFrame,
)
m.incomingUniStreams = newIncomingUniStreamsMap(
m.incomingUniStreams = newIncomingStreamsMap(
protocol.StreamTypeUni,
func(num protocol.StreamNum) receiveStreamI {
id := num.StreamID(protocol.StreamTypeUni, m.perspective.Opposite())
return newReceiveStream(id, m.sender, m.newFlowController(id), m.version)