소스 검색

yield goroutine on pipe write

Darien Raymond 7 년 전
부모
커밋
956868ef78
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      transport/pipe/impl.go

+ 4 - 0
transport/pipe/impl.go

@@ -3,6 +3,7 @@ package pipe
 import (
 import (
 	"errors"
 	"errors"
 	"io"
 	"io"
+	"runtime"
 	"sync"
 	"sync"
 	"time"
 	"time"
 
 
@@ -125,6 +126,9 @@ func (p *pipe) WriteMultiBuffer(mb buf.MultiBuffer) error {
 		switch {
 		switch {
 		case err == nil:
 		case err == nil:
 			p.readSignal.Signal()
 			p.readSignal.Signal()
+
+			// Yield current goroutine. Hopefully the reading counterpart can pick up the payload.
+			runtime.Gosched()
 			return nil
 			return nil
 		case err == errBufferFull && p.discardOverflow:
 		case err == errBufferFull && p.discardOverflow:
 			mb.Release()
 			mb.Release()