agentManager.go 913 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package server
  2. import "time"
  3. func (server *Server) agentManager() {
  4. // Declare variables
  5. // Agents free to run solutions
  6. var agents_free int
  7. // Tasks up for grabs
  8. var tasks_free int
  9. // Start the great for-loop
  10. for {
  11. agents_free = 0
  12. // Count the number of agents without a runnig task
  13. for key := range server.Agents {
  14. if server.Agents[key].TaskId == 0 {
  15. agents_free += 1
  16. }
  17. }
  18. // Check if there are any new Tasks up for grabs
  19. for key := range server.Tasks {
  20. if server.Tasks[key].Status == 0 {
  21. tasks_free += 1
  22. }
  23. }
  24. // See if the task can be divided by the number of agents
  25. // if agents_free > len(row1s) {} <-- Where the fuck does row1s come from?
  26. // For proof-of-conept I will just send it
  27. // If so, split
  28. // if not, split-1
  29. // Try again
  30. // Give agents task, maybe even look for the ones with the most CPUs
  31. // 😴
  32. time.Sleep(10 * time.Second)
  33. }
  34. }