Source File
debug.go
Belonging Package
runtime
// Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package runtimeimport ()// GOMAXPROCS sets the maximum number of CPUs that can be executing// simultaneously and returns the previous setting. It defaults to// the value of runtime.NumCPU. If n < 1, it does not change the current setting.// This call will go away when the scheduler improves.func ( int) int {if GOARCH == "wasm" && > 1 {= 1 // WebAssembly has no threads yet, so only one CPU is possible.}lock(&sched.lock):= int(gomaxprocs)unlock(&sched.lock)if <= 0 || == {return}stopTheWorldGC("GOMAXPROCS")// newprocs will be processed by startTheWorldnewprocs = int32()startTheWorldGC()return}// NumCPU returns the number of logical CPUs usable by the current process.//// The set of available CPUs is checked by querying the operating system// at process startup. Changes to operating system CPU allocation after// process startup are not reflected.func () int {return int(ncpu)}// NumCgoCall returns the number of cgo calls made by the current process.func () int64 {var int64for := (*m)(atomic.Loadp(unsafe.Pointer(&allm))); != nil; = .alllink {+= int64(.ncgocall)}return}// NumGoroutine returns the number of goroutines that currently exist.func () int {return int(gcount())}//go:linkname debug_modinfo runtime/debug.modinfofunc () string {return modinfo}