cpuset

package
v1.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCPUSetStr

func GenerateCPUSetStr(cpuset []int32) string

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 IsEqualStrCpus(a, b string) bool

func MergeCPUSet

func MergeCPUSet(old, new []int32) []int32

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

func ParseCPUSet(cpus *CPUSet) []int32

ParseCPUSet parses CPUSet object into an int32 slice eg. { elem: { 0:{}, 1:{}, 5:{}, 6:{}, 7:{} } } => [0,1,5,6,7]

func ParseCPUSetStr

func ParseCPUSetStr(cpusetStr string) ([]int32, error)

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

func MustParse(s string) CPUSet

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 NewCPUSet

func NewCPUSet(cpus ...int) CPUSet

NewCPUSet returns a new CPUSet containing the supplied elements.

func Parse

func Parse(s string) (CPUSet, error)

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) Clone

func (s CPUSet) Clone() CPUSet

Clone returns a copy of this CPUSet.

func (CPUSet) Contains

func (s CPUSet) Contains(cpu int) bool

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

func (CPUSet) Difference

func (s CPUSet) Difference(s2 CPUSet) CPUSet

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

func (s CPUSet) Equals(s2 CPUSet) bool

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

func (s CPUSet) Filter(predicate func(int) bool) CPUSet

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

func (s CPUSet) FilterNot(predicate func(int) bool) CPUSet

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

func (s CPUSet) Intersection(s2 CPUSet) CPUSet

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) IsEmpty

func (s CPUSet) IsEmpty() bool

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

func (CPUSet) IsSubsetOf

func (s CPUSet) IsSubsetOf(s2 CPUSet) bool

IsSubsetOf returns true if the supplied CPUSet contains all the elements

func (CPUSet) MarshalText

func (s CPUSet) MarshalText() ([]byte, error)

func (CPUSet) Size

func (s CPUSet) Size() int

Size returns the number of elements in this CPUSet.

func (CPUSet) String

func (s CPUSet) String() 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

func (s CPUSet) ToInt32Slice() []int32

ToInt32Slice returns a slice of int32 values that contains all elements from this CPUSet.

func (CPUSet) ToSlice

func (s CPUSet) ToSlice() []int

ToSlice returns a slice of integers that contains all elements from this CPUSet.

func (CPUSet) ToSliceNoSort

func (s CPUSet) ToSliceNoSort() []int

ToSliceNoSort returns a slice of integers that contains all elements from this CPUSet.

func (CPUSet) Union

func (s CPUSet) Union(s2 CPUSet) CPUSet

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

func (s CPUSet) UnionAll(s2 []CPUSet) CPUSet

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

func (s CPUSet) UnionSlice(s2 ...int) CPUSet

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

func (s *CPUSet) UnmarshalText(data []byte) error

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.

Jump to

Keyboard shortcuts

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