// Get returns an element from the pool.
// If the pool is empty, or the returned element is not usable,
// nil or the result of the New function will be returned
483504
func (bp *Pool) Get(params ...interface{}) interface{} {
	res := bp.pool.Poll()
	if res == nil || (bp.IsUsable != nil && !bp.IsUsable(res, params...)) {
		// not usable, so finalize
		if res != nil && bp.Finalize != nil {
			bp.Finalize(res)
		}

		if bp.New != nil {
			res = bp.New(params...)
		}
	}

	return res
}
999757
func (s *Selection) Get(index int) *html.Node {
	if index < 0 {
		index += len(s.Nodes) // Negative index gets from the end
	}
	return s.Nodes[index]
}
618803
func (v Int64) Get(deflt int64) int64 {
	if !v.Defined {
		return deflt
	}
	return v.V
}
1188152
func (cp *Pool) Get(ctx context.Context) (*DBConn, error) {
	span, ctx := trace.NewSpan(ctx, "Pool.Get")
	defer span.Finish()

	if cp.isCallerIDAppDebug(ctx) {
		return NewDBConnNoPool(cp.appDebugParams, cp.dbaPool)
	}
	p := cp.pool()
	if p == nil {
		return nil, ErrConnPoolClosed
	}
	span.Annotate("capacity", p.Capacity())
	span.Annotate("in_use", p.InUse())
	span.Annotate("available", p.Available())
	span.Annotate("active", p.Active())

	r, err := p.Get(ctx)
	if err != nil {
		return nil, err
	}
	return r.(*DBConn), nil
}
194168
func (c *channelPool) Get() (IOSession, error) {
	conns := c.getConns()
	if conns == nil {
		return nil, ErrClosed
	}

	// wrap our connections with out custom net.Conn implementation (wrapConn
	// method) that puts the connection back to the pool if it's closed.
	select {
	case conn := <-conns:
		if conn == nil {
			return nil, ErrClosed
		}

		return conn, nil
	default:
		conn, err := c.factory()
		if err != nil {
			return nil, err
		}

		return conn, nil
	}
}
629284
func (p *cbPool) Get(ptr unsafe.Pointer) interface{} {
	p.m.RLock()
	defer p.m.RUnlock()
	p.checkPointer(ptr)
	id := *(*int)(ptr) - 1
	if id == -1 {
		panic("Attempt to get nonexistent value from pool")
	}
	return p.objects[id]
}
1112745
func (p *StatePool) Get(modelUUID string) (*PooledState, error) {
	p.mu.Lock()
	defer p.mu.Unlock()

	if p.pool == nil {
		return nil, errors.New("pool is closed")
	}

	if modelUUID == p.systemState.ModelUUID() {
		return newPooledState(p.systemState, p, modelUUID, true), nil
	}

	item, ok := p.pool[modelUUID]
	if ok && item.remove {
		// Disallow further usage of a pool item marked for removal.
		return nil, errors.NewNotFound(nil, fmt.Sprintf("model %v has been removed", modelUUID))
	}

	p.sourceKey++
	key := p.sourceKey

	source := string(debug.Stack())

	// Already have a state in the pool for this model; use it.
	if ok {
		item.referenceSources[key] = source
		ps := newPooledState(item.state, p, modelUUID, false)
		ps.itemKey = key
		return ps, nil
	}

	// Don't create any new pool objects if the state pool is in the
	// process of closing down.
	if p.closing {
		return nil, errors.New("pool is closing")
	}

	// We need a new state and pool item.
	st, err := p.openState(modelUUID)
	if err != nil {
		return nil, errors.Trace(err)
	}
	p.pool[modelUUID] = &PoolItem{
		modelUUID: modelUUID,
		state:     st,
		referenceSources: map[uint64]string{
			key: source,
		},
	}
	ps := newPooledState(st, p, modelUUID, false)
	ps.itemKey = key
	return ps, nil
}
500671
func (v Float64) Get(deflt float64) float64 {
	if !v.Defined {
		return deflt
	}
	return v.V
}
206604
func (e *Error) Get() error {
	e.lock.RLock()
	defer e.lock.RUnlock()

	return e.err
}
183146
func (rl *List) Get(index int64) (string, error) {
	conn := rl.pool.Get(rl.dbindex)
	result, err := conn.Do("LINDEX", rl.id)
	if err != nil {
		panic(err)
	}
	return redis.String(result, err)
}
1121944
func (rkv *KeyValue) Get(key string) (string, error) {
	conn := rkv.pool.Get(rkv.dbindex)
	result, err := redis.String(conn.Do("GET", rkv.id+":"+key))
	if err != nil {
		return "", err
	}
	return result, nil
}
399585
func (bp *BytePoolCap) Get() (b []byte) {
	select {
	case b = <-bp.c:
	// reuse existing buffer
	default:
		// create new buffer
		if bp.wcap > 0 {
			b = make([]byte, bp.w, bp.wcap)
		} else {
			b = make([]byte, bp.w)
		}
	}
	return
}
715087
func (e Error) Get() (error, error) {
	if !e.Present() {
		var zero error
		return zero, errors.New("value not present")
	}
	return *e.value, nil
}
118879
func (h *HashMap) Get(elementid, key string) (val string, err error) {
	if h.name == nil {
		return "", ErrDoesNotExist
	}
	err = (*bbolt.DB)(h.db).View(func(tx *bbolt.Tx) error {
		bucket := tx.Bucket(h.name)
		if bucket == nil {
			return ErrBucketNotFound
		}
		byteval := bucket.Get([]byte(elementid + ":" + key))
		if byteval == nil {
			return ErrKeyNotFound
		}
		val = string(byteval)
		return nil // Return from View function
	})
	return
}
751153
func (f *Values) Get(key string) []string {
	var results []string
	for i, v := range f.values {
		if v.Key == key {
			results = append(results, f.values[i].Value)
		}
	}
	return results
}
103212
func (bp *SizedBufferPool) Get() (b *bytes.Buffer) {
	select {
	case b = <-bp.c:
	// reuse existing buffer
	default:
		// create new buffer
		b = bytes.NewBuffer(make([]byte, 0, bp.a))
	}
	return
}
1017007
func (p *Pool) Get(size int) (interface{}, int) {
	n := p.size(size)
	if pool := p.pool[n]; pool != nil {
		return pool.Get(), n
	}
	return nil, size
}