|
|
- #pragma once
-
- #include "gp_config.hpp"
- #include "gp/function.hpp"
- #include "gp/indexed_array.hpp"
- #include "gp/pointers.hpp"
- #include "gp/vfs/file_description.hpp"
- #include "gp/vfs/platforms/platform_autopicker.hpp"
-
- #include <atomic>
-
- namespace gp {
-
- enum class process_status {
- inactive = 0,
- running = 1,
- waiting = 2,
- finished = 3,
- zombie = 4
- };
-
- using pid_t = size_t;
-
- struct process_data{
- pid_t pid;
- gp::function<void()> fn;
- void* stack;
- size_t stack_sz;
- gp::process_status state;
- std::atomic_bool is_running;
- [[no_unique_address]] gp::specifics::platform_data specifics;
- gp::indexed_array<gp::file_description*, gp_config::limits::max_fd_per_process> fds;
-
- process_data(gp::function<void()> _fn, void* _stack, size_t _stack_sz)
- : fn(_fn)
- , stack(_stack)
- , stack_sz(_stack_sz)
- , state(gp::process_status::inactive)
- , specifics(gp::buffer<char>{(char*)stack, stack_sz})
- {}
- };
-
- }
|