mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-11 22:43:40 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user