From: Martin Quinson Date: Fri, 5 Feb 2021 08:37:20 +0000 (+0100) Subject: CommImpl: don't mix state and type, and make type_ const X-Git-Tag: v3.27~436^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/edcfbaedc5a51f1d1d7b7597d1d857b3ac19c908 CommImpl: don't mix state and type, and make type_ const --- diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index c57f0a7746..630a2c2488 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -69,7 +69,6 @@ XBT_PRIVATE simgrid::kernel::activity::ActivityImplPtr simcall_HANDLER_comm_isen XBT_DEBUG("Receive already pushed"); other_comm->state_ = simgrid::kernel::activity::State::READY; - other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::READY); } if (detached) { @@ -136,7 +135,7 @@ simcall_HANDLER_comm_irecv(smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_ if (other_comm->surf_action_ && other_comm->get_remaining() < 1e-12) { XBT_DEBUG("comm %p has been already sent, and is finished, destroy it", other_comm.get()); other_comm->state_ = simgrid::kernel::activity::State::DONE; - other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::DONE).set_mailbox(nullptr); + other_comm->set_mailbox(nullptr); } } } else { @@ -158,7 +157,6 @@ simcall_HANDLER_comm_irecv(smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_ XBT_DEBUG("Match my %p with the existing %p", this_synchro.get(), other_comm.get()); other_comm->state_ = simgrid::kernel::activity::State::READY; - other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::READY); } receiver->activities_.emplace_back(other_comm); } @@ -365,12 +363,6 @@ namespace simgrid { namespace kernel { namespace activity { -CommImpl& CommImpl::set_type(CommImpl::Type type) -{ - type_ = type; - return *this; -} - CommImpl& CommImpl::set_size(double size) { size_ = size; diff --git a/src/kernel/activity/CommImpl.hpp b/src/kernel/activity/CommImpl.hpp index 195209d422..e9485d664a 100644 --- a/src/kernel/activity/CommImpl.hpp +++ b/src/kernel/activity/CommImpl.hpp @@ -26,12 +26,11 @@ class XBT_PUBLIC CommImpl : public ActivityImpl_T { MailboxImpl* mbox_ = nullptr; /* Rendez-vous where the comm is queued */ public: - enum class Type { SEND = 0, RECEIVE, READY, DONE }; + enum class Type { SEND, RECEIVE }; CommImpl(Type type) : type_(type) {} CommImpl(s4u::Host* from, s4u::Host* to, double bytes); - CommImpl& set_type(CommImpl::Type type); CommImpl& set_size(double size); CommImpl& set_src_buff(unsigned char* buff, size_t size); CommImpl& set_dst_buff(unsigned char* buff, size_t* size); @@ -52,7 +51,7 @@ public: void post() override; void finish() override; - CommImpl::Type type_; /* Type of the communication (SEND or RECEIVE) */ + const CommImpl::Type type_; /* Type of the communication (SEND or RECEIVE) */ #if SIMGRID_HAVE_MC MailboxImpl* mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR diff --git a/src/mc/api.cpp b/src/mc/api.cpp index 89f93c5c09..6c1504d75a 100644 --- a/src/mc/api.cpp +++ b/src/mc/api.cpp @@ -118,7 +118,7 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta const simgrid::kernel::activity::CommImpl* act = temp_act.get_buffer(); if (act->src_actor_.get() && act->dst_actor_.get()) state->transition_.argument_ = 0; // OK - else if (act->src_actor_.get() == nullptr && act->type_ == simgrid::kernel::activity::CommImpl::Type::READY && + else if (act->src_actor_.get() == nullptr && act->state_ == simgrid::kernel::activity::State::READY && act->detached()) state->transition_.argument_ = 0; // OK else diff --git a/src/mc/mc_base.cpp b/src/mc/mc_base.cpp index 5cc8b4930e..8274ec2b0c 100644 --- a/src/mc/mc_base.cpp +++ b/src/mc/mc_base.cpp @@ -102,8 +102,7 @@ bool actor_is_enabled(smx_actor_t actor) return true; } /* On the other hand if it hasn't a timeout, check if the comm is ready.*/ - else if (act->detached() && act->src_actor_ == nullptr && - act->type_ == simgrid::kernel::activity::CommImpl::Type::READY) + else if (act->detached() && act->src_actor_ == nullptr && act->state_ == simgrid::kernel::activity::State::READY) return (act->dst_actor_ != nullptr); return (act->src_actor_ && act->dst_actor_); }