moby/pkg/sysinfo/numcpu.go
Sebastiaan van Stijn 6919b9879b
pkg/sysinfo: unify NumCPU implementation
Use a single exported implementation, so that we can maintain the
GoDoc string in one place, and use non-exported functions for the
actual implementation (which were already in place).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-21 10:53:42 +01:00

15 lines
371 B
Go

package sysinfo // import "github.com/docker/docker/pkg/sysinfo"
import (
"runtime"
)
// NumCPU returns the number of CPUs. On Linux and Windows, it returns
// the number of CPUs which are currently online. On other platforms,
// it's the equivalent of [runtime.NumCPU].
func NumCPU() int {
if ncpu := numCPU(); ncpu > 0 {
return ncpu
}
return runtime.NumCPU()
}