hide unused api

This commit is contained in:
xtaci
2020-01-16 22:23:37 +08:00
parent 5e1b1674e1
commit 6da22a180e
+3 -13
View File
@@ -68,7 +68,7 @@ func (s *Stream) ID() uint32 {
// Read implements net.Conn // Read implements net.Conn
func (s *Stream) Read(b []byte) (n int, err error) { func (s *Stream) Read(b []byte) (n int, err error) {
for { for {
n, err = s.TryRead(b) n, err = s.tryRead(b)
if err == ErrWouldBlock { if err == ErrWouldBlock {
if ew := s.waitRead(); ew != nil { if ew := s.waitRead(); ew != nil {
return 0, ew return 0, ew
@@ -79,18 +79,8 @@ func (s *Stream) Read(b []byte) (n int, err error) {
} }
} }
// PeekSize returns the next size for Read // tryRead is the nonblocking version of Read
func (s *Stream) PeekSize() int { func (s *Stream) tryRead(b []byte) (n int, err error) {
s.bufferLock.Lock()
defer s.bufferLock.Unlock()
if len(s.buffers) > 0 {
return len(s.buffers[0])
}
return 0
}
// TryRead is the nonblocking version of Read
func (s *Stream) TryRead(b []byte) (n int, err error) {
if s.sess.config.Version == 2 { if s.sess.config.Version == 2 {
return s.tryReadv2(b) return s.tryReadv2(b)
} }