backend: add parameter to launch a number of generation workers

This commit is contained in:
nemunaire 2019-10-12 15:50:31 +02:00
commit c2c5cf4ce3
2 changed files with 8 additions and 1 deletions

View file

@ -28,6 +28,7 @@ type genStruct struct {
Type GenerateType
}
var parallelJobs = runtime.NumCPU()
var genTeamQueue chan *fic.Team
var genQueue chan genStruct
var inQueueMutex sync.RWMutex
@ -37,8 +38,11 @@ func init() {
genTeamQueue = make(chan *fic.Team)
genQueue = make(chan genStruct)
inGenQueue = map[GenerateType]bool{}
}
for i := runtime.NumCPU(); i > 0; i-- {
func launchWorkers() {
log.Println("Running with", parallelJobs, "worker(s)")
for i := parallelJobs; i > 0; i-- {
go consumer()
}
}