General Purpose library for Freestanding C++ and POSIX systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
857 B

3 years ago
  1. #pragma once
  2. #include "gp/containers/indexed_array.hpp"
  3. #include "gp/system/process_data.hpp"
  4. #include "gp/system/task_queue.hpp"
  5. namespace gp {
  6. namespace system {
  7. class system;
  8. /**
  9. * @brief The class that handles the scheduling globally in a system
  10. */
  11. struct scheduler {
  12. task_queue::node_ptr previous;
  13. task_queue::node_ptr current;
  14. size_t id;
  15. system& sys;
  16. process_data main_context_data;
  17. task_queue::node main_context;
  18. no_inline_decl(
  19. void yield_to(task_queue::node_ptr target)
  20. );
  21. scheduler(system&, size_t token);
  22. scheduler(scheduler&& v)
  23. : previous(v.previous)
  24. , current(v.current)
  25. , id(v.id)
  26. , sys(v.sys)
  27. , main_context_data(gp::move(v.main_context_data))
  28. , main_context(gp::move(v.main_context))
  29. {}
  30. void run();
  31. void yield();
  32. ~scheduler() {
  33. }
  34. };
  35. }
  36. }