"errors"
"io"
"os"
+ "runtime"
"sync"
"sync/atomic"
"syscall"
if !block {
full = pq.full
}
+
+ // Before we check dt.expired, yield to other goroutines.
+ // This may help to prevent starvation of the goroutine that runs the
+ // deadlineTimer's time.After callback.
+ //
+ // TODO(#65178): Remove this when the runtime scheduler no longer starves
+ // runnable goroutines.
+ runtime.Gosched()
+
select {
case <-dt.expired:
return 0, os.ErrDeadlineExceeded
// (Without this, TestZeroByteRead deadlocks.)
empty = pq.empty
}
+
+ // Before we check dt.expired, yield to other goroutines.
+ // This may help to prevent starvation of the goroutine that runs the
+ // deadlineTimer's time.After callback.
+ //
+ // TODO(#65178): Remove this when the runtime scheduler no longer starves
+ // runnable goroutines.
+ runtime.Gosched()
+
select {
case <-dt.expired:
return 0, nil, os.ErrDeadlineExceeded