Drop EofReader

This is not used any more

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
This commit is contained in:
Alexander Larsson 2014-02-14 13:00:18 +01:00
parent f198ee525a
commit d8c888b3f8
1 changed files with 0 additions and 27 deletions

View File

@ -6,8 +6,6 @@ import (
"github.com/dotcloud/docker/pkg/namesgenerator"
"github.com/dotcloud/docker/runconfig"
"github.com/dotcloud/docker/utils"
"io"
"sync/atomic"
)
type Change struct {
@ -56,28 +54,3 @@ func (c *checker) Exists(name string) bool {
func generateRandomName(runtime *Runtime) (string, error) {
return namesgenerator.GenerateRandomName(&checker{runtime})
}
// Read an io.Reader and call a function when it returns EOF
func EofReader(r io.Reader, callback func()) *eofReader {
return &eofReader{
Reader: r,
callback: callback,
}
}
type eofReader struct {
io.Reader
gotEOF int32
callback func()
}
func (r *eofReader) Read(p []byte) (n int, err error) {
n, err = r.Reader.Read(p)
if err == io.EOF {
// Use atomics to make the gotEOF check threadsafe
if atomic.CompareAndSwapInt32(&r.gotEOF, 0, 1) {
r.callback()
}
}
return
}