mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	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:
		
							parent
							
								
									f198ee525a
								
							
						
					
					
						commit
						d8c888b3f8
					
				
					 1 changed files with 0 additions and 27 deletions
				
			
		
							
								
								
									
										27
									
								
								utils.go
									
										
									
									
									
								
							
							
						
						
									
										27
									
								
								utils.go
									
										
									
									
									
								
							| 
						 | 
					@ -6,8 +6,6 @@ import (
 | 
				
			||||||
	"github.com/dotcloud/docker/pkg/namesgenerator"
 | 
						"github.com/dotcloud/docker/pkg/namesgenerator"
 | 
				
			||||||
	"github.com/dotcloud/docker/runconfig"
 | 
						"github.com/dotcloud/docker/runconfig"
 | 
				
			||||||
	"github.com/dotcloud/docker/utils"
 | 
						"github.com/dotcloud/docker/utils"
 | 
				
			||||||
	"io"
 | 
					 | 
				
			||||||
	"sync/atomic"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Change struct {
 | 
					type Change struct {
 | 
				
			||||||
| 
						 | 
					@ -56,28 +54,3 @@ func (c *checker) Exists(name string) bool {
 | 
				
			||||||
func generateRandomName(runtime *Runtime) (string, error) {
 | 
					func generateRandomName(runtime *Runtime) (string, error) {
 | 
				
			||||||
	return namesgenerator.GenerateRandomName(&checker{runtime})
 | 
						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
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue