// getNumThreads - gets the number of threads to be used in the multipart
// put object operation
192216
func (opts PutObjectOptions) getNumThreads() (numThreads int) {
	if opts.NumThreads > 0 {
		numThreads = int(opts.NumThreads)
	} else {
		numThreads = totalWorkers
	}
	return
}
1084167
func (t *Table) NumRows() int {
	t.mu.RLock()
	defer t.mu.RUnlock()
	return len(t.Data)
}
366727
func (c *Counter) Get() int {
	c.Lock()
	defer c.Unlock()
	return c.count
}
1201299
func (cm *ClusterMesh) NumReadyClusters() int {
	cm.mutex.RLock()
	defer cm.mutex.RUnlock()

	nready := 0
	for _, cm := range cm.clusters {
		if cm.isReady() {
			nready++
		}
	}

	return nready
}
254706
func (h *Handle) GetPartitionStats(tblInfo *model.TableInfo, pid int64) *statistics.Table {
	tbl, ok := h.StatsCache.Load().(StatsCache)[pid]
	if !ok {
		tbl = statistics.PseudoTable(tblInfo)
		tbl.PhysicalID = pid
		h.UpdateTableStats([]*statistics.Table{tbl}, nil)
		return tbl
	}
	return tbl
}
459454
func (c *Chunk) NumRows() int {
	if c.NumCols() == 0 {
		return c.numVirtualRows
	}
	return c.columns[0].length
}
279928
func (wsh *WebsocketHub) NumClients() int {
	// Swallow any type assertion error since the default int of 0 is OK.
	n, _ := wsh.numClients.Load().(int)
	return n
}
753565
func (l *State) ToThread(index int) *State {
	if t, ok := l.indexToValue(index).(*State); ok {
		return t
	}
	return nil
}
944804
func (sq *servingQueue) setThreads(threadCount int) {
	select {
	case sq.setThreadsCh <- threadCount:
	case <-sq.quit:
		return
	}
}
1248772
func (m *MemoryManager) GetAll(limit, offset int64) (Policies, error) {
	keys := make([]string, len(m.Policies))
	i := 0
	m.RLock()
	for key := range m.Policies {
		keys[i] = key
		i++
	}

	start, end := pagination.Index(int(limit), int(offset), len(m.Policies))
	sort.Strings(keys)
	ps := make(Policies, len(keys[start:end]))
	i = 0
	for _, key := range keys[start:end] {
		ps[i] = m.Policies[key]
		i++
	}
	m.RUnlock()
	return ps, nil
}
270752
func (sq *servingQueue) threadCountLoop() {
	var threadCountTarget int
	for {
		for threadCountTarget > sq.threadCount {
			sq.wg.Add(1)
			go sq.threadController()
			sq.threadCount++
		}
		if threadCountTarget < sq.threadCount {
			select {
			case threadCountTarget = <-sq.setThreadsCh:
			case sq.stopThreadCh <- struct{}{}:
				sq.threadCount--
			case <-sq.quit:
				sq.wg.Done()
				return
			}
		} else {
			select {
			case threadCountTarget = <-sq.setThreadsCh:
			case <-sq.quit:
				sq.wg.Done()
				return
			}
		}
	}
}
714972
func (i *Index) availableThreads() int {
	n := runtime.GOMAXPROCS(0)
	if len(i.partitions) < n {
		return len(i.partitions)
	}
	return n
}
789374
func (l *State) PushThread() bool {
	l.apiPush(l)
	return l.global.mainThread == l
}
911342
func (n defaultNumSlice) get(i int) int {
	if len(n) > i {
		return n[i]
	}
	return 0
}
242853
func (soc *Socket) GetThreadSafe() (bool, error) {
	if minor < 2 {
		return false, ErrorNotImplemented42
	}
	v, err := soc.getInt(C.ZMQ_THREAD_SAFE)
	return v != 0, err
}
879437
func parseThreadSample(b *bytes.Buffer) (nextl string, addrs []uint64, err error) {
	var l string
	sameAsPrevious := false
	for {
		if l, err = b.ReadString('\n'); err != nil {
			if err != io.EOF {
				return "", nil, err
			}
			if l == "" {
				break
			}
		}
		if l = strings.TrimSpace(l); l == "" {
			continue
		}

		if strings.HasPrefix(l, "---") {
			break
		}
		if strings.Contains(l, "same as previous thread") {
			sameAsPrevious = true
			continue
		}

		addrs = append(addrs, parseHexAddresses(l)...)
	}

	if sameAsPrevious {
		return l, nil, nil
	}
	return l, addrs, nil
}
213597
func (prod *AwsCloudwatchLogs) numEvents(messages []*core.Message, checkFn ...indexNumFn) int {
	index := maxBatchEvents
	for _, fn := range checkFn {
		result := fn(messages)
		if result < index {
			index = result
		}
	}
	return index
}