forked from quic-go/quic-go
simplify the stream by directly popping STREAM frames from it
This commit is contained in:
@@ -12,10 +12,9 @@ type cryptoStreamI interface {
|
||||
io.Reader
|
||||
io.Writer
|
||||
AddStreamFrame(*wire.StreamFrame) error
|
||||
HasDataForWriting() bool
|
||||
GetDataForWriting(maxBytes protocol.ByteCount) (data []byte, shouldSendFin bool)
|
||||
GetWriteOffset() protocol.ByteCount
|
||||
PopStreamFrame(protocol.ByteCount) *wire.StreamFrame
|
||||
Cancel(error)
|
||||
HasDataForWriting() bool
|
||||
SetReadOffset(protocol.ByteCount)
|
||||
// methods needed for flow control
|
||||
GetWindowUpdate() protocol.ByteCount
|
||||
@@ -27,6 +26,8 @@ type cryptoStream struct {
|
||||
*stream
|
||||
}
|
||||
|
||||
var _ cryptoStreamI = &cryptoStream{}
|
||||
|
||||
func newCryptoStream(onData func(), flowController flowcontrol.StreamFlowController, version protocol.VersionNumber) cryptoStreamI {
|
||||
str := newStream(version.CryptoStreamID(), onData, nil, flowController, version)
|
||||
return &cryptoStream{str}
|
||||
@@ -39,3 +40,10 @@ func (s *cryptoStream) SetReadOffset(offset protocol.ByteCount) {
|
||||
s.readOffset = offset
|
||||
s.frameQueue.readPosition = offset
|
||||
}
|
||||
|
||||
func (s *cryptoStream) HasDataForWriting() bool {
|
||||
s.mutex.Lock()
|
||||
hasData := s.dataForWriting != nil
|
||||
s.mutex.Unlock()
|
||||
return hasData
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user