General Purpose library for Freestanding C++ and POSIX systems
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

42 rindas
927 B

  1. #pragma once
  2. #include "gp_config.hpp"
  3. #include "gp/function.hpp"
  4. #include "gp/indexed_array.hpp"
  5. #include "gp/pointers.hpp"
  6. #include "gp/vfs/file_description.hpp"
  7. #include "gp/vfs/platforms/platform_autopicker.hpp"
  8. #include <atomic>
  9. namespace gp {
  10. enum class process_status {
  11. inactive = 0,
  12. running = 1,
  13. waiting = 2,
  14. finished = 3,
  15. zombie = 4
  16. };
  17. using pid_t = size_t;
  18. struct process_data{
  19. pid_t pid;
  20. gp::function<void()> fn;
  21. void* stack;
  22. size_t stack_sz;
  23. gp::process_status state;
  24. std::atomic_bool is_running;
  25. [[no_unique_address]] gp::specifics::platform_data specifics;
  26. gp::indexed_array<gp::file_description*, gp_config::limits::max_fd_per_process> fds;
  27. process_data(gp::function<void()> _fn, void* _stack, size_t _stack_sz)
  28. : fn(_fn)
  29. , stack(_stack)
  30. , stack_sz(_stack_sz)
  31. , state(gp::process_status::inactive)
  32. , specifics(gp::buffer<char>{(char*)stack, stack_sz})
  33. {}
  34. };
  35. }