X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/77bbf3027c4240a2e833209a3a3f186589da8577..61ab0b23d55ea10365ba11d22b8c11b39cbf16e9:/src/simix/ActorImpl.hpp diff --git a/src/simix/ActorImpl.hpp b/src/simix/ActorImpl.hpp index 06d42dc7da..15bfeb04cb 100644 --- a/src/simix/ActorImpl.hpp +++ b/src/simix/ActorImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -9,7 +9,7 @@ #include "simgrid/s4u/Actor.hpp" #include "src/simix/popping_private.hpp" #include "src/surf/PropertyHolder.hpp" -#include "xbt/swag.h" +#include #include #include @@ -19,17 +19,30 @@ struct s_smx_process_exit_fun_t { }; namespace simgrid { -namespace simix { +namespace kernel { +namespace actor { class ProcessArg { public: std::string name; std::function code; - void *data = nullptr; - sg_host_t host = nullptr; + void* data = nullptr; + s4u::Host* host = nullptr; double kill_time = 0.0; std::shared_ptr> properties; bool auto_restart = false; + ProcessArg() = default; + explicit ProcessArg(std::string name, std::function code, void* data, s4u::Host* host, double kill_time, + std::shared_ptr> properties, bool auto_restart) + : name(name) + , code(std::move(code)) + , data(data) + , host(host) + , kill_time(kill_time) + , properties(properties) + , auto_restart(auto_restart) + { + } }; class ActorImpl : public simgrid::surf::PropertyHolder { @@ -37,40 +50,35 @@ public: ActorImpl() : piface_(this) {} ~ActorImpl(); - // TODO, replace with boost intrusive container hooks - s_xbt_swag_hookup_t process_hookup = { nullptr, nullptr }; /* simix_global->process_list */ - s_xbt_swag_hookup_t synchro_hookup = { nullptr, nullptr }; /* {mutex,cond,sem}->sleeping */ - s_xbt_swag_hookup_t host_proc_hookup = { nullptr, nullptr }; /* smx_host->process_lis */ - s_xbt_swag_hookup_t destroy_hookup = { nullptr, nullptr }; /* simix_global->process_to_destroy */ + boost::intrusive::list_member_hook<> host_process_list_hook; /* simgrid::simix::Host::process_list */ + boost::intrusive::list_member_hook<> smx_destroy_list_hook; /* simix_global->process_to_destroy */ + boost::intrusive::list_member_hook<> smx_synchro_hook; /* {mutex,cond,sem}->sleeping */ aid_t pid = 0; aid_t ppid = -1; simgrid::xbt::string name; - const simgrid::xbt::string& getName() const { return name; } - const char* getCname() const { return name.c_str(); } + const simgrid::xbt::string& get_name() const { return name; } + const char* get_cname() const { return name.c_str(); } s4u::Host* host = nullptr; /* the host on which the process is running */ smx_context_t context = nullptr; /* the context (uctx/raw/thread) that executes the user function */ - // TODO, pack them std::exception_ptr exception; bool finished = false; bool blocked = false; bool suspended = false; bool auto_restart = false; - sg_host_t new_host = nullptr; /* if not null, the host on which the process must migrate to */ smx_activity_t waiting_synchro = nullptr; /* the current blocking synchro if any */ std::list comms; /* the current non-blocking communication synchros */ - s_smx_simcall_t simcall; - void* userdata = nullptr; /* kept for compatibility, it should be replaced with moddata */ + s_smx_simcall simcall; std::vector on_exit; /* list of functions executed when the process dies */ std::function code; smx_timer_t kill_timer = nullptr; - int segment_index = -1; /* Reference to an SMPI process' data segment. Default value is -1 if not in SMPI context*/ - /* Refcounting */ private: + void* userdata = nullptr; /* kept for compatibility, it should be replaced with moddata */ + /* Refcounting */ std::atomic_int_fast32_t refcount_{0}; public: @@ -115,14 +123,17 @@ public: void* getUserData() { return userdata; } }; -} -} - -typedef simgrid::simix::ProcessArg *smx_process_arg_t; +/* Used to keep the list of actors blocked on a synchro */ +typedef boost::intrusive::list, + &ActorImpl::smx_synchro_hook>> + SynchroList; -typedef simgrid::simix::ActorImpl* smx_actor_t; +XBT_PUBLIC void create_maestro(std::function code); +} +} // namespace kernel +} // namespace simgrid -extern "C" { +typedef simgrid::kernel::actor::ActorImpl* smx_actor_t; XBT_PRIVATE smx_actor_t SIMIX_process_create(const char* name, std::function code, void* data, sg_host_t host, std::map* properties, @@ -130,19 +141,15 @@ XBT_PRIVATE smx_actor_t SIMIX_process_create(const char* name, std::function