cpuset

package
v1.27.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cpuset represents a collection of CPUs in a 'set' data structure.

It can be used to represent core IDs, hyper thread siblings, CPU nodes, or processor IDs.

The only special thing about this package is that methods are provided to convert back and forth from Linux 'list' syntax. See http://man7.org/linux/man-pages/man7/cpuset.7.html#FORMATS for details.

Future work can migrate this to use a 'set' library, and relax the dubious 'immutable' property.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUSet

type CPUSet struct {
	// contains filtered or unexported fields
}

CPUSet is a thread-safe, immutable set-like data structure for CPU IDs.

func New added in v1.27.0

func New(cpus ...int) CPUSet

New returns a new CPUSet containing the supplied elements.

func Parse

func Parse(s string) (CPUSet, error)

Parse CPUSet constructs a new CPU set from a Linux CPU list formatted string.

See: http://man7.org/linux/man-pages/man7/cpuset.7.html#FORMATS

func (CPUSet) Clone

func (s CPUSet) Clone() CPUSet

Clone returns a copy of this CPU set.

func (CPUSet) Contains

func (s CPUSet) Contains(cpu int) bool

Contains returns true if the supplied element is present in this set.

func (CPUSet) Difference

func (s CPUSet) Difference(s2 CPUSet) CPUSet

Difference returns a new CPU set that contains all of the elements that are present in this set and not the supplied set, without mutating either source set.

func (CPUSet) Equals

func (s CPUSet) Equals(s2 CPUSet) bool

Equals returns true if the supplied set contains exactly the same elements as this set (s IsSubsetOf s2 and s2 IsSubsetOf s).

func (CPUSet) Intersection

func (s CPUSet) Intersection(s2 CPUSet) CPUSet

Intersection returns a new CPU set that contains all of the elements that are present in both this set and the supplied set, without mutating either source set.

func (CPUSet) IsEmpty

func (s CPUSet) IsEmpty() bool

IsEmpty returns true if there are zero elements in this set.

func (CPUSet) IsSubsetOf

func (s CPUSet) IsSubsetOf(s2 CPUSet) bool

IsSubsetOf returns true if the supplied set contains all the elements

func (CPUSet) List added in v1.27.0

func (s CPUSet) List() []int

List returns a slice of integers that contains all elements from this set. The list is sorted.

func (CPUSet) Size

func (s CPUSet) Size() int

Size returns the number of elements in this set.

func (CPUSet) String

func (s CPUSet) String() string

String returns a new string representation of the elements in this CPU set in canonical linux CPU list format.

See: http://man7.org/linux/man-pages/man7/cpuset.7.html#FORMATS

func (CPUSet) Union

func (s CPUSet) Union(s2 ...CPUSet) CPUSet

Union returns a new CPU set that contains all of the elements from this set and all of the elements from the supplied sets, without mutating either source set.

func (CPUSet) UnsortedList added in v1.27.0

func (s CPUSet) UnsortedList() []int

UnsortedList returns a slice of integers that contains all elements from this set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL