mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 04:11:03 +00:00
23 lines
324 B
Go
23 lines
324 B
Go
|
package queue
|
||
|
|
||
|
import (
|
||
|
"runtime"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
// get the number of CPUs. Since builds
|
||
|
// tend to be CPU-intensive we should only
|
||
|
// execute 1 build per CPU.
|
||
|
ncpu := runtime.NumCPU()
|
||
|
|
||
|
// must be at least 1
|
||
|
if ncpu < 1 {
|
||
|
ncpu = 1
|
||
|
}
|
||
|
|
||
|
// spawn a worker for each CPU
|
||
|
for i := 0; i < ncpu; i++ {
|
||
|
go work()
|
||
|
}
|
||
|
}
|