runtime: implement NumCPU for -scheduler=threads

For the threads scheduler, it makes sense to have NumCPU available.
For all other schedulers, the number of available CPUs is practically
limited to one by the scheduler (even though the system might have more
CPUs).
This commit is contained in:
Ayke van Laethem
2025-01-21 11:10:18 +01:00
parent 3767decf9e
commit cce44b5ebb
7 changed files with 34 additions and 12 deletions
+5
View File
@@ -50,6 +50,11 @@ func Gosched() {
// operation, so is probably best not to use.
}
// NumCPU returns the number of logical CPUs usable by the current process.
func NumCPU() int {
return task.NumCPU()
}
// Separate goroutine (thread) that runs timer callbacks when they expire.
func timerRunner() {
for {