numcpu.go 371 B

123456789101112131415
  1. package sysinfo // import "github.com/docker/docker/pkg/sysinfo"
  2. import (
  3. "runtime"
  4. )
  5. // NumCPU returns the number of CPUs. On Linux and Windows, it returns
  6. // the number of CPUs which are currently online. On other platforms,
  7. // it's the equivalent of [runtime.NumCPU].
  8. func NumCPU() int {
  9. if ncpu := numCPU(); ncpu > 0 {
  10. return ncpu
  11. }
  12. return runtime.NumCPU()
  13. }