backend: add parameter to launch a number of generation workers
This commit is contained in:
parent
97a3aa713f
commit
c2c5cf4ce3
2 changed files with 8 additions and 1 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue