// newBufioWriterPoolWithSize is unexported because new pools should be
// added here to be shared where required.
515622
func newBufioWriterPoolWithSize(size int) *BufioWriterPool {
	return &BufioWriterPool{
		pool: sync.Pool{
			New: func() interface{} { return bufio.NewWriterSize(nil, size) },
		},
	}
}
609791
func NewPool(
	bytesPool pool.CheckedBytesPool,
	opts PoolOptions,
) Pool {
	opts = opts.defaultsIfNotSet()

	p := &simplePool{
		bytesPool: bytesPool,
		pool:      pool.NewObjectPool(opts.IDPoolOptions),
		tagArrayPool: newTagArrayPool(tagArrayPoolOpts{
			Options:     opts.TagsPoolOptions,
			Capacity:    opts.TagsCapacity,
			MaxCapacity: opts.TagsMaxCapacity,
		}),
		itersPool: pool.NewObjectPool(opts.TagsIteratorPoolOptions),
	}
	p.pool.Init(func() interface{} {
		return &id{pool: p}
	})
	p.tagArrayPool.Init()
	p.itersPool.Init(func() interface{} {
		return newTagSliceIter(Tags{}, p)
	})

	return p
}
597548
func NewPool(parentCtx context.Context) *Pool {
	baseCtx, baseCancel := context.WithCancel(parentCtx)
	ctx, cancel := context.WithCancel(baseCtx)
	return &Pool{
		baseCtx:    baseCtx,
		baseCancel: baseCancel,
		ctx:        ctx,
		cancel:     cancel,
	}
}
1190180
func NewPool(network, addr string, size int) (*Pool, error) {
	return NewCustomPool(network, addr, size, redis.Dial)
}
594179
func NewDriverPool(connStr string, max int) (DriverPool, error) {
	return createDriverPool(connStr, max)
}
250741
func NewFloatsPool(sizes []Bucket, opts ObjectPoolOptions) FloatsPool {
	return &floatsPool{pool: NewBucketizedObjectPool(sizes, opts)}
}
764958
func NewPool(capacity int, itemFactory ItemFactory) (Pool, error) {

	q, err := queue.NewChannelQueue(capacity)
	if err != nil {
		return nil, err
	}

	itemMap := make(map[uint64]*Item)
	pool := itemPool{itemMap: itemMap, itemQ: q, capacity: capacity, itemFactory: itemFactory}
	return &pool, nil
}
615231
func (pool *LoadBalancedPool) SetActiveSetSize(size uint64) {
	pool.lock.Lock()
	defer pool.lock.Unlock()
	pool.activeSetSize = size
}
305091
func (_class PoolUpdateClass) GetInstallationSize(sessionID SessionRef, self PoolUpdateRef) (_retval int, _err error) {
	_method := "pool_update.get_installation_size"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertPoolUpdateRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertIntToGo(_method + " -> ", _result.Value)
	return
}
861583
func NewBufReaderAt(readerAt io.ReaderAt, size int) *BufReaderAt {
	if size < minBufferSize {
		size = minBufferSize
	}

	return &BufReaderAt{
		offset:     0,
		readerAt:   readerAt,
		buf:        make([]byte, size),
		sizeTilEOF: sizeNotInitialized,
	}
}
1362609
func NewWriter(dest io.Writer, state ws.State, op ws.OpCode) *Writer {
	return NewWriterBufferSize(dest, state, op, 0)
}
595822
func NewPoolInfoCache(size int) (*PoolInfoCache, error) {
	if size < 2 {
		return nil, fmt.Errorf("size %d is less than 2", size)
	}
	return &PoolInfoCache{
		poolInfo:    make(map[chainhash.Hash]*apitypes.TicketPoolInfo, size),
		expireQueue: make([]chainhash.Hash, 0, size),
		maxSize:     size,
	}, nil
}
1164782
func NewByteBufPool(capacity int, pool Pool) *ByteBuf {
	return &ByteBuf{
		capacity:    capacity,
		buf:         pool.Alloc(capacity),
		readerIndex: 0,
		writerIndex: 0,
		pool:        pool,
	}
}
1257148
func (c *Client) CreatePool(pname, provider string, attrs map[string]interface{}) error {
	// Older facade did not support bulk calls.
	if c.BestAPIVersion() < 5 {
		args := params.StoragePool{
			Name:     pname,
			Provider: provider,
			Attrs:    attrs,
		}
		return c.facade.FacadeCall("CreatePool", args, nil)
	}

	var results params.ErrorResults
	args := params.StoragePoolArgs{
		Pools: []params.StoragePool{{
			Name:     pname,
			Provider: provider,
			Attrs:    attrs,
		}},
	}

	if err := c.facade.FacadeCall("CreatePool", args, &results); err != nil {
		return errors.Trace(err)
	}
	return results.OneError()
}
198324
func SetBufferSize(i int) FileConfig {
	return func(t *File) error {
		t.ring = rbuf.NewFixedSizeRingBuf(i)
		return nil
	}
}
82938
func bufioWriterBuffer(originalWriter io.Writer, bw *bufio.Writer) []byte {
	// This code assumes that bufio.Writer.buf[:1] is passed to the
	// bufio.Writer's underlying writer.
	var wh writeHook
	bw.Reset(&wh)
	bw.WriteByte(0)
	bw.Flush()

	bw.Reset(originalWriter)

	return wh.p[:cap(wh.p)]
}
69322
func NewWALSegmentWriter(w io.WriteCloser) *WALSegmentWriter {
	return &WALSegmentWriter{
		bw: bufio.NewWriterSize(w, 16*1024),
		w:  w,
	}
}