From: Frederic Suter Date: Thu, 24 Oct 2019 12:35:23 +0000 (+0200) Subject: make HostImpl::actor_list_ private X-Git-Tag: v3.25~489 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/078b9d03609d4f0072a2d968f792bbdd9a1fe08d?hp=e329e2e6aa39ca2d2317ddd4b9ea83250ac98f8e make HostImpl::actor_list_ private --- diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index afb141f154..78be44fcf9 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -98,7 +98,7 @@ ActorImplPtr ActorImpl::attach(const std::string& name, void* data, s4u::Host* h actor->set_properties(*properties); /* Add the process to it's host process list */ - host->pimpl_->actor_list_.push_back(*actor); + host->pimpl_->add_actor(actor); /* Now insert it in the global process list and in the process to run list */ simix_global->process_list[actor->get_pid()] = actor; @@ -172,7 +172,7 @@ void ActorImpl::cleanup() simix_global->process_list.erase(pid_); if (host_ && host_actor_list_hook.is_linked()) - simgrid::xbt::intrusive_erase(host_->pimpl_->actor_list_, *this); + host_->pimpl_->remove_actor(this); if (not smx_destroy_list_hook.is_linked()) { #if SIMGRID_HAVE_MC xbt_dynar_push_as(simix_global->dead_actors_vector, ActorImpl*, this); @@ -443,9 +443,9 @@ void ActorImpl::simcall_answer() void ActorImpl::set_host(s4u::Host* dest) { - xbt::intrusive_erase(host_->pimpl_->actor_list_, *this); + host_->pimpl_->remove_actor(this); host_ = dest; - dest->pimpl_->actor_list_.push_back(*this); + dest->pimpl_->add_actor(this); } ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host) @@ -477,7 +477,7 @@ ActorImpl* ActorImpl::start(const simix::ActorCode& code) XBT_DEBUG("Start context '%s'", get_cname()); /* Add the actor to its host's actor list */ - host_->pimpl_->actor_list_.push_back(*this); + host_->pimpl_->add_actor(this); simix_global->process_list[pid_] = this; /* Now insert it in the global actor list and in the actor to run list */ diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index bcbe62ab23..e499ff03d7 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -200,13 +200,13 @@ void VirtualMachineImpl::suspend(smx_actor_t issuer) throw VmFailureException(XBT_THROW_POINT, xbt::string_printf("Actor %s cannot suspend the VM %s in which it runs", issuer->get_cname(), piface_->get_cname())); - XBT_DEBUG("suspend VM(%s), where %zu actors exist", piface_->get_cname(), actor_list_.size()); + XBT_DEBUG("suspend VM(%s), where %zu actors exist", piface_->get_cname(), get_actor_count()); action_->suspend(); - for (auto& actor : actor_list_) { - XBT_DEBUG("suspend %s", actor.get_cname()); - actor.suspend(); + for (auto& actor : get_all_actors()) { + XBT_DEBUG("suspend %s", actor->get_cname()); + actor->suspend(); } XBT_DEBUG("suspend all actors on the VM done done"); @@ -220,13 +220,13 @@ void VirtualMachineImpl::resume() throw VmFailureException(XBT_THROW_POINT, xbt::string_printf("Cannot resume VM %s: it was not suspended", piface_->get_cname())); - XBT_DEBUG("Resume VM %s, containing %zu actors.", piface_->get_cname(), actor_list_.size()); + XBT_DEBUG("Resume VM %s, containing %zu actors.", piface_->get_cname(), get_actor_count()); action_->resume(); - for (auto& actor : actor_list_) { - XBT_DEBUG("resume %s", actor.get_cname()); - actor.resume(); + for (auto& actor : get_all_actors()) { + XBT_DEBUG("resume %s", actor->get_cname()); + actor->resume(); } vm_state_ = s4u::VirtualMachine::state::RUNNING; @@ -259,12 +259,12 @@ void VirtualMachineImpl::shutdown(smx_actor_t issuer) XBT_VERB("Shutting down the VM %s even if it's not running but %s", piface_->get_cname(), stateName); } - XBT_DEBUG("shutdown VM %s, that contains %zu actors", piface_->get_cname(), actor_list_.size()); + XBT_DEBUG("shutdown VM %s, that contains %zu actors", piface_->get_cname(), get_actor_count()); - for (auto& actor : actor_list_) { - XBT_DEBUG("kill %s@%s on behalf of %s which shutdown that VM.", actor.get_cname(), actor.get_host()->get_cname(), + for (auto& actor : get_all_actors()) { + XBT_DEBUG("kill %s@%s on behalf of %s which shutdown that VM.", actor->get_cname(), actor->get_host()->get_cname(), issuer->get_cname()); - issuer->kill(&actor); + issuer->kill(actor->get_impl()); } set_state(s4u::VirtualMachine::state::DESTROYED); diff --git a/src/smpi/mpi/smpi_comm.cpp b/src/smpi/mpi/smpi_comm.cpp index e8e893fe10..f6b31709ad 100644 --- a/src/smpi/mpi/smpi_comm.cpp +++ b/src/smpi/mpi/smpi_comm.cpp @@ -340,12 +340,12 @@ void Comm::unref(Comm* comm){ MPI_Comm Comm::find_intra_comm(int * leader){ //get the indices of all processes sharing the same simix host - auto& actor_list = sg_host_self()->pimpl_->actor_list_; + auto actor_list = sg_host_self()->pimpl_->get_all_actors(); int intra_comm_size = 0; int min_index = INT_MAX; // the minimum index will be the leader for (auto& actor : actor_list) { - int index = actor.get_pid(); - if (this->group()->rank(actor.ciface()) != MPI_UNDEFINED) { // Is this process in the current group? + int index = actor->get_pid(); + if (this->group()->rank(actor.get()) != MPI_UNDEFINED) { // Is this process in the current group? intra_comm_size++; if (index < min_index) min_index = index; @@ -355,8 +355,8 @@ MPI_Comm Comm::find_intra_comm(int * leader){ MPI_Group group_intra = new Group(intra_comm_size); int i = 0; for (auto& actor : actor_list) { - if (this->group()->rank(actor.ciface()) != MPI_UNDEFINED) { - group_intra->set_mapping(actor.ciface(), i); + if (this->group()->rank(actor.get()) != MPI_UNDEFINED) { + group_intra->set_mapping(actor.get(), i); i++; } } diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 1d39ec62b3..4bdaacf7ea 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -43,6 +43,12 @@ public: * @details An host represents a machine with a aggregation of a Cpu, a RoutingEdge and a Storage */ class XBT_PRIVATE HostImpl : public simgrid::surf::PropertyHolder { + typedef boost::intrusive::list< + kernel::actor::ActorImpl, + boost::intrusive::member_hook, + &kernel::actor::ActorImpl::host_actor_list_hook>> + ActorList; + ActorList actor_list_; public: explicit HostImpl(s4u::Host* host); @@ -64,15 +70,10 @@ public: void turn_off(); std::vector get_all_actors(); size_t get_actor_count(); + void add_actor(kernel::actor::ActorImpl* actor) { actor_list_.push_back(*actor); } + void remove_actor(kernel::actor::ActorImpl* actor) { xbt::intrusive_erase(actor_list_, *actor); } - typedef boost::intrusive::list< - kernel::actor::ActorImpl, - boost::intrusive::member_hook, - &kernel::actor::ActorImpl::host_actor_list_hook>> - ActorList; - - // FIXME: make these private - ActorList actor_list_; + // FIXME: make this private std::vector actors_at_boot_; }; }