// Sockets returns all of the socket IDs associated with the CPUs in this
// CPUDetails.
429402
func (d CPUDetails) Sockets() cpuset.CPUSet {
	b := cpuset.NewBuilder()
	for _, info := range d {
		b.Add(info.SocketID)
	}
	return b.Result()
}
1026520
func (m *Message_Peer) Addresses() []ma.Multiaddr {
	if m == nil {
		return nil
	}

	maddrs := make([]ma.Multiaddr, 0, len(m.Addrs))
	for _, addr := range m.Addrs {
		maddr, err := ma.NewMultiaddrBytes(addr)
		if err != nil {
			log.Warningf("error decoding Multiaddr for peer: %s", m.GetId())
			continue
		}

		maddrs = append(maddrs, maddr)
	}
	return maddrs
}
324881
func (s *server) Peers() []*peer {
	s.mu.RLock()
	defer s.mu.RUnlock()

	peers := make([]*peer, 0, len(s.peersByPub))
	for _, peer := range s.peersByPub {
		peers = append(peers, peer)
	}

	return peers
}
413844
func (prof *Profiler) Get() (*CPUs, error) {
	cpus := &CPUs{CPU: make([]CPU, prof.NumCPU)}
	var err error
	var pids []int32 // the physical ids encountered

	hasFreq := prof.hasCPUFreq()
	for x := 0; x < prof.NumCPU; x++ {
		var cpu CPU
		var found bool

		cpu.PhysicalPackageID, err = prof.physicalPackageID(x)
		if err != nil {
			return nil, err
		}
		// see if this is a new physical id; if so, add it to the inventory
		for _, v := range pids {
			if v == cpu.PhysicalPackageID {
				found = true
				break
			}
		}
		if !found {
			pids = append(pids, cpu.PhysicalPackageID)
		}
		cpu.CoreID, err = prof.coreID(x)
		if err != nil {
			return nil, err
		}
		err := prof.cache(x, &cpu)
		if err != nil {
			return nil, err
		}
		if hasFreq {
			cpu.MHzMin, err = prof.cpuMHzMin(x)
			if err != nil {
				return nil, err
			}
			cpu.MHzMax, err = prof.cpuMHzMax(x)
			if err != nil {
				return nil, err
			}
		}
		cpus.CPU[x] = cpu
	}
	cpus.Sockets = int32(len(pids))
	cpus.Possible, err = prof.Possible()
	if err != nil {
		return nil, err
	}

	cpus.Online, err = prof.Online()
	if err != nil {
		return nil, err
	}

	cpus.Offline, err = prof.Offline()
	if err != nil {
		return nil, err
	}

	cpus.Present, err = prof.Present()
	if err != nil {
		return nil, err
	}

	return cpus, nil
}
250227
func (nc *Conn) Servers() []string {
	nc.mu.RLock()
	defer nc.mu.RUnlock()
	return nc.getServers(false)
}
248444
func (r Resources) Ports() []string {
	if r.PortRanges == "" || r.PortRanges == "[]" {
		return []string{}
	}

	rhs := strings.Split(r.PortRanges, "[")[1]
	lhs := strings.Split(rhs, "]")[0]

	yports := []string{}

	mports := strings.Split(lhs, ",")
	for _, port := range mports {
		tmp := strings.TrimSpace(port)
		pz := strings.Split(tmp, "-")
		lo, err := strconv.Atoi(pz[0])
		if err != nil {
			logging.Error.Println(err)
			continue
		}
		hi, err := strconv.Atoi(pz[1])
		if err != nil {
			logging.Error.Println(err)
			continue
		}

		for t := lo; t <= hi; t++ {
			yports = append(yports, strconv.Itoa(t))
		}
	}
	return yports
}
510312
func (topo *CPUTopology) CPUsPerSocket() int {
	if topo.NumSockets == 0 {
		return 0
	}
	return topo.NumCPUs / topo.NumSockets
}
1115592
func Deserialize(p []byte) *cpux.CPUs {
	fcpus := structs.GetRootAsCPUs(p, 0)
	l := fcpus.CPULength()
	cpus := &cpux.CPUs{}
	fCPU := &structs.CPU{}
	fCache := &structs.CacheInf{}
	cpu := cpux.CPU{}
	cpus.Sockets = fcpus.Sockets()
	cpus.Possible = string(fcpus.Possible())
	cpus.Online = string(fcpus.Online())
	cpus.Present = string(fcpus.Present())
	for i := 0; i < l; i++ {
		if !fcpus.CPU(fCPU, i) {
			continue
		}
		cpu.PhysicalPackageID = fCPU.PhysicalPackageID()
		cpu.CoreID = fCPU.CoreID()
		cpu.MHzMin = fCPU.MHzMin()
		cpu.MHzMax = fCPU.MHzMax()
		caches := fCPU.CacheLength()
		cpu.CacheIDs = make([]string, 0, caches)
		cpu.Cache = make(map[string]string, caches)
		for j := 0; j < caches; j++ {
			if !fCPU.Cache(fCache, j) {
				continue
			}
			cpu.CacheIDs = append(cpu.CacheIDs, string(fCache.ID()))
			cpu.Cache[cpu.CacheIDs[j]] = string(fCache.Size())
		}
		cpus.CPU = append(cpus.CPU, cpu)
	}
	return cpus
}
1291502
func (a Nodes) IDs() []string {
	ids := make([]string, len(a))
	for i, n := range a {
		ids[i] = n.ID
	}
	return ids
}
927395
func (i sigmaInstance) Addresses(ctx context.ProviderCallContext) ([]network.Address, error) {
	ip := i.findIPv4()

	if ip != "" {
		addr := network.Address{
			Value: ip,
			Type:  network.IPv4Address,
			Scope: network.ScopePublic,
		}

		logger.Tracef("sigmaInstance.Addresses: %v", addr)

		return []network.Address{addr}, nil
	}
	return []network.Address{}, nil
}
1093753
func (m *machineTracker) Addresses() []network.Address {
	m.mu.Lock()
	defer m.mu.Unlock()
	out := make([]network.Address, len(m.addresses))
	copy(out, m.addresses)
	return out
}
1338278
func Socket(bind string) net.Listener {
	l, err := listenTo(bind)
	if err != nil {
		log.Fatal(err)
	}
	return l
}
131416
func (soc Socket) String() string {
	if !soc.opened {
		return "Socket(CLOSED)"
	}
	t, err := soc.GetType()
	if err != nil {
		return fmt.Sprintf("Socket(%v)", err)
	}
	i, err := soc.GetIdentity()
	if err == nil && i != "" {
		return fmt.Sprintf("Socket(%v,%q)", t, i)
	}
	return fmt.Sprintf("Socket(%v,%p)", t, soc.soc)
}
706789
func (c *lruCache) IDs() []uint64 {
	a := make([]uint64, 0, len(c.counts))
	for id := range c.counts {
		a = append(a, id)
	}
	sort.Sort(uint64Slice(a))
	return a
}
199151
func Serialize(cpus *cpux.CPUs) (p []byte) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std = NewProfiler()
	}
	return std.Serialize(cpus)
}
1274863
func (s *Server) Channels() []string {
	channels := []string{}

	for name := range s.channels {
		channels = append(channels, name)
	}

	return channels
}
1117683
func (s *Socket) Close() error {
	if s.err != nil {
		// nothing to close
		return nil
	}

	defer s.conn.Close()

	if err := s.enc.Flush(); err != nil {
		return fmt.Errorf("flush: %s", err)
	}
	return s.enc.Close()
}