// IdleLen returns number of idle connections.
552375
func (p *ConnPool) IdleLen() int {
	p.connsMu.Lock()
	n := p.idleConnsLen
	p.connsMu.Unlock()
	return n
}
1007515
func CycleLen(minNumOldBuckets int) DBConfiguration {
	return func(c *CycleDB) error {
		c.minNumOldBuckets = minNumOldBuckets
		return nil
	}
}
422746
func toLen(s string, args ...string) string {
	return strconv.Itoa(len(s))
}
927463
func (ps *peerSet) NodeDataIdlePeers() ([]*peerConnection, int) {
	idle := func(p *peerConnection) bool {
		return atomic.LoadInt32(&p.stateIdle) == 0
	}
	throughput := func(p *peerConnection) float64 {
		p.lock.RLock()
		defer p.lock.RUnlock()
		return p.stateThroughput
	}
	return ps.idlePeers(63, 64, idle, throughput)
}
1353691
func (s *Server) ClientsLen() int {
	s.mu.Lock()
	defer s.mu.Unlock()
	return len(s.peers)
}
399966
func (ctn *Connection) refresh() {
	ctn.idleDeadline = time.Now().Add(ctn.idleTimeout)
}
743888
func (m *Miniredis) CurrentConnectionCount() int {
	m.Lock()
	defer m.Unlock()
	return m.srv.ClientsLen()
}
84221
func (p *simpleResourcePool) NumIdle() int {
	p.mutex.Lock()
	defer p.mutex.Unlock()
	return len(p.idleHandles)
}
928056
func (ps *peerSet) idlePeers(minProtocol, maxProtocol int, idleCheck func(*peerConnection) bool, throughput func(*peerConnection) float64) ([]*peerConnection, int) {
	ps.lock.RLock()
	defer ps.lock.RUnlock()

	idle, total := make([]*peerConnection, 0, len(ps.peers)), 0
	for _, p := range ps.peers {
		if p.version >= minProtocol && p.version <= maxProtocol {
			if idleCheck(p) {
				idle = append(idle, p)
			}
			total++
		}
	}
	for i := 0; i < len(idle); i++ {
		for j := i + 1; j < len(idle); j++ {
			if throughput(idle[i]) < throughput(idle[j]) {
				idle[i], idle[j] = idle[j], idle[i]
			}
		}
	}
	return idle, total
}
1076165
func Intn(n int) int {
	mu.Lock()
	res := r.Intn(n)
	mu.Unlock()
	return res
}
479177
func (lr *LockedRand) Intn(n int) (r int) {
	lr.lk.Lock()
	r = lr.r.Intn(n)
	lr.lk.Unlock()
	return
}
866236
func (c *Connection) IsIdle(idleTimeout time.Duration) bool {
	return time.Since(c.lastActivity) > idleTimeout && c.msgStore.Size() == 0
}
901429
func (vs *VertexSlice) SetLen(len int) {
	vs.End() // vs must have been Begin-ed before calling this method
	*vs = vs.grow(len)
	vs.Begin()
}
93558
func (r *Random) WithLen(length int) *Random {
	r.len = &length
	return r
}
850565
func (c *Client) getIdleConn() (*persistentConn, error) {

	// First check for available connections in the channel.
Loop:
	for {
		select {
		case pconn := <-c.freeConnCh:
			if pconn.broken {
				c.debug("#%d was ready (broken)", pconn.idx)
				c.mu.Lock()
				c.numConnsPerHost[pconn.host]--
				c.mu.Unlock()
				c.removeConn(pconn)
			} else {
				c.debug("#%d was ready", pconn.idx)
				return pconn, nil
			}
		default:
			break Loop
		}
	}

	// No available connections. Loop until we can open a new one, or
	// one becomes available.
	for {
		c.mu.Lock()

		// can we open a connection to some host
		if c.numOpenConns() < len(c.hosts)*c.config.ConnectionsPerHost {
			c.connIdx++
			idx := c.connIdx

			// find the next host with less than ConnectionsPerHost connections
			var host string
			for i := idx; i < idx+len(c.hosts); i++ {
				if c.numConnsPerHost[c.hosts[i%len(c.hosts)]] < c.config.ConnectionsPerHost {
					host = c.hosts[i%len(c.hosts)]
					break
				}
			}

			if host == "" {
				panic("this shouldn't be possible")
			}

			c.numConnsPerHost[host]++

			c.mu.Unlock()

			pconn, err := c.openConn(idx, host)
			if err != nil {
				c.mu.Lock()
				c.numConnsPerHost[host]--
				c.mu.Unlock()
				c.debug("#%d error connecting: %s", idx, err)
			}
			return pconn, err
		}

		c.mu.Unlock()

		// block waiting for a free connection
		pconn := <-c.freeConnCh

		if pconn.broken {
			c.debug("waited and got #%d (broken)", pconn.idx)
			c.mu.Lock()
			c.numConnsPerHost[pconn.host]--
			c.mu.Unlock()
			c.removeConn(pconn)
		} else {
			c.debug("waited and got #%d", pconn.idx)
			return pconn, nil

		}
	}
}
91205
func (f *File) NumConns() int {
	f.connsLock.Lock()
	defer f.connsLock.Unlock()

	return len(f.conns)
}
203565
func (s *Server) NumClients() int {
	s.mu.Lock()
	defer s.mu.Unlock()
	return len(s.clients)
}