package solver

import (
	"fmt"
	"strconv"
	"time"
)

func (solver *Solver) ManageSolver() {

	for rows1Index := range solver.row1s {

		// Sleep a while when there are more or an equal number of Go routines running
		for solver.cores >= solver.Controller.NumCPUs {
			time.Sleep(time.Duration(1))
		}

		// Luanch a solver in its separate go routine
		fmt.Println(strconv.Itoa(solver.cores) + ">=" + strconv.Itoa(solver.Controller.NumCPUs))
		solver.cores = solver.cores + 1
		go solver.CheckCombinationsLevel1(rows1Index)
	}

}
