mirror of
https://github.com/xtaci/smux.git
synced 2024-04-21 10:51:48 +00:00
hide unused api
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user