summaryrefslogtreecommitdiffstats
path: root/up.go
diff options
context:
space:
mode:
authorMateusz Czapliński <czapkofan@gmail.com>2018-03-10 21:31:08 +0100
committerMateusz Czapliński <czapkofan@gmail.com>2018-03-10 21:31:08 +0100
commit32c7b859eb8e51585bf7994af555b32fd33fafb2 (patch)
treecc607d1de2f626fa477cdae6dc6c59690cb07494 /up.go
parentea178bcade42f17c5806b5b02f005a1c5d8a0f66 (diff)
quick and dirty workaround for busy wait
Diffstat (limited to 'up.go')
-rw-r--r--up.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/up.go b/up.go
index 6e45410..e073658 100644
--- a/up.go
+++ b/up.go
@@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"sync"
+ "time"
"unicode/utf8"
"github.com/mattn/go-isatty"
@@ -181,10 +182,14 @@ func (b *Buf) NewReader() io.Reader {
b.nLock.Lock()
end := b.n
b.nLock.Unlock()
- // TODO: don't return (0,nil), instead wait until at least 1 available,
- // or return EOF on completion?
n = copy(p, b.bytes[i:end])
i += n
+ if n == 0 {
+ // FIXME: GROSS HACK! To avoid busy-wait in caller, don't return
+ // (0,nil), instead wait until at least 1 available, or return (0,
+ // io.EOF) on completion
+ time.Sleep(100 * time.Millisecond)
+ }
return n, nil
})
}