// NewWithGenericPool creates and returns a new RedSync instance from given generic Pools.
778931
func NewWithGenericPool(genericNodes []Pool) *RedSync {
	if len(genericNodes) == 0 {
		panic("redsync: genericNodes is empty")
	}

	return &RedSync{
		pools: genericNodes,
	}
}
351518
func NewGenericRecord(schema Schema) *GenericRecord {
	return &GenericRecord{
		fields: make(map[string]interface{}),
		schema: schema,
	}
}
574639
func (r *Spec) newGenericResource(sourceFs afero.Fs,
	targetPathBuilder func() page.TargetPaths,
	osFileInfo os.FileInfo,
	sourceFilename,
	baseFilename string,
	mediaType media.Type) *genericResource {
	return r.newGenericResourceWithBase(
		sourceFs,
		false,
		nil,
		nil,
		targetPathBuilder,
		osFileInfo,
		sourceFilename,
		baseFilename,
		mediaType,
	)

}
913680
func Pool() *sync.Pool {
	v := new(sync.Pool)
	v.New = func() interface{} {
		return NewFromPool(v)
	}
	return v
}
1129070
func New(workers int, jobQueue ...int) *WorkerPool {
	q := 0
	if len(jobQueue) > 0 && jobQueue[0] > 0 {
		q = jobQueue[0]
	}
	if workers < 0 {
		workers = runtime.NumCPU()
	}
	pool := WorkerPool{
		pool: make(chan chan func(), workers),
		jobs: make(chan func(), q),
		quit: make(chan struct{}),
		wg:   sync.WaitGroup{},
	}
	for i := 0; i < workers; i++ {
		initWorker(pool.pool, 0, nil, pool.quit, &pool.wg)
	}
	go pool.dispatch()
	return &pool
}
1293281
func (rc *RedisConnector) NewPool(socketPath, host, password string, db int, cnf *config.RedisConfig, tlsConfig *tls.Config) *redis.Pool {
	if cnf == nil {
		cnf = defaultConfig
	}
	return &redis.Pool{
		MaxIdle:     cnf.MaxIdle,
		IdleTimeout: time.Duration(cnf.IdleTimeout) * time.Second,
		MaxActive:   cnf.MaxActive,
		Wait:        cnf.Wait,
		Dial: func() (redis.Conn, error) {
			c, err := rc.open(socketPath, host, password, db, cnf, tlsConfig)
			if err != nil {
				return nil, err
			}

			if db != 0 {
				_, err = c.Do("SELECT", db)
				if err != nil {
					return nil, err
				}
			}

			return c, err
		},
		// PINGs connections that have been idle more than 10 seconds
		TestOnBorrow: func(c redis.Conn, t time.Time) error {
			if time.Since(t) < time.Duration(10*time.Second) {
				return nil
			}
			_, err := c.Do("PING")
			return err
		},
	}
}
583657
func NewBufferPool(size int, mem int) (bp *BufferPool) {
	return &BufferPool{
		c:     make(chan *bytes.Buffer, size),
		alloc: mem,
	}
}
1264825
func newPoolEntryQueue(maxCnt int, removeFromPool func(*poolEntry)) poolEntryQueue {
	return poolEntryQueue{queue: make(map[int]*poolEntry), maxCnt: maxCnt, removeFromPool: removeFromPool}
}
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
}
947518
func NewWithPrefix(pool *redis.Pool, prefix string) *RedisStore {
	return &RedisStore{
		pool:   pool,
		prefix: prefix,
	}
}
651501
func NewPoolCache() *poolCache {
	return &poolCache{
		mutex: sync.RWMutex{},
		dirty: true,
		pools: make([]pool.ReadPool, 0),
	}
}
669650
func New(c *tlc.Container, source wsync.Pool, cache wsync.WritablePool) *CachePool {
	cp := &CachePool{
		container: c,
		source:    source,
		cache:     cache,
		fileChans: make([]chan struct{}, len(c.Files)),
	}

	for i := range cp.fileChans {
		cp.fileChans[i] = make(chan struct{})
	}

	return cp
}
1076784
func NewGenericNACK() Body {
	b := newGenericNACK(&Header{ID: GenericNACKID})
	b.init()
	return b
}
519207
func NewObjectPoolWithDefaultConfig(ctx context.Context, factory PooledObjectFactory) *ObjectPool {
	return NewObjectPool(ctx, factory, NewDefaultPoolConfig())
}
869842
func NewBytePool() BytePool {
	return BytePool{
		tinySlab:   newByteSlab(tiny, tinyCount),
		smallSlab:  newByteSlab(small, smallCount),
		mediumSlab: newByteSlab(medium, mediumCount),
		largeSlab:  newByteSlab(large, largeCount),
		hugeSlab:   newByteSlab(huge, hugeCount),
	}
}
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,
	}
}
1264904
func NewGenericStorage(name string, options GenericStorageOptions) Storage {
	return &GenericStorage{
		name:         name,
		get:          options.GetFunc,
		getMulti:     options.GetMultiFunc,
		set:          options.SetFunc,
		setMulti:     options.SetMultiFunc,
		del:          options.DelFunc,
		delMulti:     options.DelMultiFunc,
		errorOnFlush: options.ErrorOnFlush,
		flush:        options.FlushFunc,
	}
}