Documentation ¶
Index ¶
- func GenerateCPUSetStr(cpuset []int32) string
- func IsEqualStrCpus(a, b string) bool
- func MergeCPUSet(old, new []int32) []int32
- func ParseCPUSet(cpus *CPUSet) []int32
- func ParseCPUSetStr(cpusetStr string) ([]int32, error)
- type CPUSet
- func (s CPUSet) Clone() CPUSet
- func (s CPUSet) Contains(cpu int) bool
- func (s CPUSet) Difference(s2 CPUSet) CPUSet
- func (s CPUSet) Equals(s2 CPUSet) bool
- func (s CPUSet) Filter(predicate func(int) bool) CPUSet
- func (s CPUSet) FilterNot(predicate func(int) bool) CPUSet
- func (s CPUSet) Intersection(s2 CPUSet) CPUSet
- func (s CPUSet) IsEmpty() bool
- func (s CPUSet) IsSubsetOf(s2 CPUSet) bool
- func (s CPUSet) MarshalText() ([]byte, error)
- func (s CPUSet) Size() int
- func (s CPUSet) String() string
- func (s CPUSet) ToInt32Slice() []int32
- func (s CPUSet) ToSlice() []int
- func (s CPUSet) ToSliceNoSort() []int
- func (s CPUSet) Union(s2 CPUSet) CPUSet
- func (s CPUSet) UnionAll(s2 []CPUSet) CPUSet
- func (s CPUSet) UnionSlice(s2 ...int) CPUSet
- func (s *CPUSet) UnmarshalText(data []byte) error
- type CPUSetBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCPUSetStr ¶
GenerateCPUSetStr generates the cpuset string from the cpuset slice eg. [3,2,1,0] => "3,2,1,0"
func IsEqualStrCpus ¶ added in v1.2.0
func MergeCPUSet ¶
MergeCPUSet merges the old cpuset with the new one, and also deduplicate and keeps a desc order by processor ids e.g. [1,0], [3,2,2,1] => [3,2,1,0]
func ParseCPUSet ¶
ParseCPUSet parses CPUSet object into an int32 slice eg. { elem: { 0:{}, 1:{}, 5:{}, 6:{}, 7:{} } } => [0,1,5,6,7]
func ParseCPUSetStr ¶
ParseCPUSetStr parses cpuset string into a slice eg. "0-5,34,46-48" => [0,1,2,3,4,5,34,46,47,48]
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 MustParse ¶
MustParse CPUSet constructs a new CPUSet from a Linux CPU list formatted string. Unlike Parse, it does not return an error but rather panics if the input cannot be used to construct a CPUSet.
func Parse ¶
Parse CPUSet constructs a new CPUSet from a Linux CPU list formatted string.
See: http://man7.org/linux/man-pages/man7/cpuset.7.html#FORMATS
func (CPUSet) Difference ¶
Difference returns a new CPUSet that contains the elements that are present in this CPUSet and not the supplied CPUSet, without mutating either source CPUSet.
func (CPUSet) Equals ¶
Equals returns true if the supplied CPUSet contains exactly the same elements as this CPUSet (s IsSubsetOf s2 and s2 IsSubsetOf s).
func (CPUSet) Filter ¶
Filter returns a new CPUSet that contains the elements from this CPUSet that match the supplied predicate, without mutating the source CPUSet.
func (CPUSet) FilterNot ¶
FilterNot returns a new CPUSet that contains the elements from this CPUSet that do not match the supplied predicate, without mutating the source CPUSet.
func (CPUSet) Intersection ¶
Intersection returns a new CPUSet that contains the elements that are present in both this CPUSet and the supplied CPUSet, without mutating either source CPUSet.
func (CPUSet) IsSubsetOf ¶
IsSubsetOf returns true if the supplied CPUSet contains all the elements
func (CPUSet) MarshalText ¶
func (CPUSet) String ¶
String returns a new string representation of the elements in this CPUSet in canonical linux CPU list format.
See: http://man7.org/linux/man-pages/man7/cpuset.7.html#FORMATS
func (CPUSet) ToInt32Slice ¶
ToInt32Slice returns a slice of int32 values that contains all elements from this CPUSet.
func (CPUSet) ToSlice ¶
ToSlice returns a slice of integers that contains all elements from this CPUSet.
func (CPUSet) ToSliceNoSort ¶
ToSliceNoSort returns a slice of integers that contains all elements from this CPUSet.
func (CPUSet) Union ¶
Union returns a new CPUSet that contains the elements from this CPUSet and the elements from the supplied CPUSet, without mutating either source CPUSet.
func (CPUSet) UnionAll ¶
UnionAll returns a new CPUSet that contains the elements from this CPUSet and the elements from the supplied sets, without mutating either source CPUSet.
func (CPUSet) UnionSlice ¶
UnionSlice returns a new CPUSet that contains the elements from this CPUSet and the elements from the supplied CPUSet, without mutating either source CPUSet.
func (*CPUSet) UnmarshalText ¶
type CPUSetBuilder ¶
type CPUSetBuilder struct {
// contains filtered or unexported fields
}
CPUSetBuilder is a mutable builder for CPUSet. Functions that mutate instances of this type are not thread-safe.
func NewCPUSetBuilder ¶
func NewCPUSetBuilder() *CPUSetBuilder
NewCPUSetBuilder returns a mutable CPUSet builder.
func (*CPUSetBuilder) Add ¶
func (b *CPUSetBuilder) Add(elems ...int)
Add adds the supplied elements to the result. Calling Add after calling Result has no effect.
func (*CPUSetBuilder) Result ¶
func (b *CPUSetBuilder) Result() CPUSet
Result returns the result CPUSet containing all elements that were previously added to this builder. Subsequent calls to Add have no effect.