mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Remove pools_nopool.go & build tag from pools.go
Fix #11576 Signed-off-by: Gleb Shepelev <shepelyov.g@gmail.com>
This commit is contained in:
		
							parent
							
								
									6fb8bd0450
								
							
						
					
					
						commit
						f01d755cd0
					
				
					 2 changed files with 0 additions and 75 deletions
				
			
		| 
						 | 
				
			
			@ -1,5 +1,3 @@
 | 
			
		|||
// +build go1.3
 | 
			
		||||
 | 
			
		||||
// Package pools provides a collection of pools which provide various
 | 
			
		||||
// data types with buffers. These can be used to lower the number of
 | 
			
		||||
// memory allocations and reuse buffers.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,73 +0,0 @@
 | 
			
		|||
// +build !go1.3
 | 
			
		||||
 | 
			
		||||
package pools
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bufio"
 | 
			
		||||
	"io"
 | 
			
		||||
 | 
			
		||||
	"github.com/docker/docker/pkg/ioutils"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	BufioReader32KPool *BufioReaderPool
 | 
			
		||||
	BufioWriter32KPool *BufioWriterPool
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const buffer32K = 32 * 1024
 | 
			
		||||
 | 
			
		||||
type BufioReaderPool struct {
 | 
			
		||||
	size int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	BufioReader32KPool = newBufioReaderPoolWithSize(buffer32K)
 | 
			
		||||
	BufioWriter32KPool = newBufioWriterPoolWithSize(buffer32K)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newBufioReaderPoolWithSize(size int) *BufioReaderPool {
 | 
			
		||||
	return &BufioReaderPool{size: size}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (bufPool *BufioReaderPool) Get(r io.Reader) *bufio.Reader {
 | 
			
		||||
	return bufio.NewReaderSize(r, bufPool.size)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (bufPool *BufioReaderPool) Put(b *bufio.Reader) {
 | 
			
		||||
	b.Reset(nil)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (bufPool *BufioReaderPool) NewReadCloserWrapper(buf *bufio.Reader, r io.Reader) io.ReadCloser {
 | 
			
		||||
	return ioutils.NewReadCloserWrapper(r, func() error {
 | 
			
		||||
		if readCloser, ok := r.(io.ReadCloser); ok {
 | 
			
		||||
			return readCloser.Close()
 | 
			
		||||
		}
 | 
			
		||||
		return nil
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type BufioWriterPool struct {
 | 
			
		||||
	size int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newBufioWriterPoolWithSize(size int) *BufioWriterPool {
 | 
			
		||||
	return &BufioWriterPool{size: size}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (bufPool *BufioWriterPool) Get(w io.Writer) *bufio.Writer {
 | 
			
		||||
	return bufio.NewWriterSize(w, bufPool.size)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (bufPool *BufioWriterPool) Put(b *bufio.Writer) {
 | 
			
		||||
	b.Reset(nil)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (bufPool *BufioWriterPool) NewWriteCloserWrapper(buf *bufio.Writer, w io.Writer) io.WriteCloser {
 | 
			
		||||
	return ioutils.NewWriteCloserWrapper(w, func() error {
 | 
			
		||||
		buf.Flush()
 | 
			
		||||
		if writeCloser, ok := w.(io.WriteCloser); ok {
 | 
			
		||||
			return writeCloser.Close()
 | 
			
		||||
		}
 | 
			
		||||
		return nil
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue