From 128ac505627fd618f339fb2944310855619a4d6c Mon Sep 17 00:00:00 2001 From: Ludovic 'Archivist' Lagouardette Date: Fri, 2 Apr 2021 16:28:10 +0200 Subject: [PATCH] ! untested changes --- include/gp/vfs/process_data.hpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/include/gp/vfs/process_data.hpp b/include/gp/vfs/process_data.hpp index f9f5e8b..a44e5db 100644 --- a/include/gp/vfs/process_data.hpp +++ b/include/gp/vfs/process_data.hpp @@ -21,6 +21,16 @@ namespace gp { using pid_t = size_t; + struct base_process_info { + virtual void initialize() {} + virtual void checkpoint() {} + virtual void restore() {} + virtual void switch_in() {} + virtual void switch_out() {} + virtual void cleanup() {} + virtual ~base_process_info() {} + }; + struct process_data{ pid_t pid; gp::function fn; @@ -29,14 +39,15 @@ namespace gp { gp::process_status state; std::atomic_bool is_running; [[no_unique_address]] gp::specifics::platform_data specifics; - gp::indexed_array fds; + gp::unique_ptr info; - process_data(gp::function _fn, void* _stack, size_t _stack_sz) + process_data(gp::function _fn, void* _stack, size_t _stack_sz, gp::unique_ptr&& _info) : fn(_fn) , stack(_stack) , stack_sz(_stack_sz) , state(gp::process_status::inactive) , specifics(gp::buffer{(char*)stack, stack_sz}) + , info(_info) {} process_data(process_data&& v) @@ -45,7 +56,14 @@ namespace gp { , stack_sz(v.stack_sz) , state(v.state) , specifics(v.specifics) + , info(gp::move(v.info)) {} + + ~process_data() { + if(info) { + info->cleanup(); + } + } }; } \ No newline at end of file