MCPcopy Create free account
hub / github.com/containerd/cgroups / extractQuotaAndPeriod

Method extractQuotaAndPeriod

cgroup2/cpu.go:56–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54}
55
56func (c CPUMax) extractQuotaAndPeriod() (int64, uint64, error) {
57 var (
58 quota int64 = math.MaxInt64
59 period uint64 = defaultCPUMaxPeriod
60 err error
61 )
62
63 // value: quota [period]
64 values := strings.Split(string(c), " ")
65 if len(values) < 1 || len(values) > 2 {
66 return 0, 0, ErrInvalidFormat
67 }
68
69 if strings.ToLower(values[0]) != defaultCPUMax {
70 quota, err = strconv.ParseInt(values[0], 10, 64)
71 if err != nil {
72 return 0, 0, err
73 }
74 }
75
76 if len(values) == 2 {
77 period, err = strconv.ParseUint(values[1], 10, 64)
78 if err != nil {
79 return 0, 0, err
80 }
81 }
82
83 return quota, period, nil
84}
85
86func (r *CPU) Values() (o []Value) {
87 if r.Weight != nil {

Callers 2

NewSystemdFunction · 0.80

Calls

no outgoing calls

Tested by 1