task_manager.alc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. include "io.alh"
  2. include "primitives.alh"
  3. include "metamodels.alh"
  4. include "core_algorithm.alh"
  5. include "random.alh"
  6. Void function task_management():
  7. String taskname
  8. Element task_root
  9. Element task_frame
  10. Element output_value
  11. Element input_value
  12. // Initialize the basic formalisms before allowing new users
  13. initialize_MMs()
  14. initialize_core()
  15. taskname = "task_manager"
  16. while (True):
  17. if (other_has_output("task_manager")):
  18. sleep(0.05)
  19. else:
  20. // Task is gone, so make sure that we create a new one already
  21. while (dict_in(read_root(), taskname)):
  22. taskname = cast_string(random_string(20))
  23. task_root = create_node()
  24. task_frame = create_node()
  25. output_value = create_node()
  26. input_value = create_node()
  27. dict_add_fast(task_root, "frame", task_frame)
  28. dict_add_fast(task_root, "globals", create_node())
  29. dict_add_fast(task_root, "output", output_value)
  30. dict_add_fast(task_root, "last_output", output_value)
  31. dict_add_fast(task_root, "input", input_value)
  32. dict_add_fast(task_root, "last_input", input_value)
  33. dict_add_fast(task_frame, "evalstack", create_node())
  34. dict_add_fast(task_frame, "returnvalue", create_node())
  35. dict_add_fast(task_frame, "phase", "init")
  36. dict_add_fast(task_frame, "IP", dict_read(dict_read(read_root(), "__hierarchy"), "__IP"))
  37. dict_add_fast(task_frame, "symbols", create_node())
  38. //Add this only at the end, as otherwise the task will already be detected
  39. dict_add_fast(read_root(), taskname, task_root)
  40. output(taskname)
  41. return!