github.com/rish1988/moby@v25.0.2+incompatible/pkg/sysinfo/numcpu.go (about)

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