From 76f5257ad1d80be9046790e7df5a1b5f6d9584ba Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 5 Apr 2019 16:19:59 +0200 Subject: [PATCH] factor simcall/activity binding --- src/kernel/activity/ActivityImpl.cpp | 7 +++++++ src/kernel/activity/ActivityImpl.hpp | 1 + src/kernel/activity/CommImpl.cpp | 3 +-- src/kernel/activity/ExecImpl.cpp | 3 +-- src/kernel/activity/IoImpl.cpp | 3 +-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/kernel/activity/ActivityImpl.cpp b/src/kernel/activity/ActivityImpl.cpp index 54540506b1..c5f3524539 100644 --- a/src/kernel/activity/ActivityImpl.cpp +++ b/src/kernel/activity/ActivityImpl.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/kernel/activity/ActivityImpl.hpp" +#include "src/simix/smx_private.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process); @@ -17,6 +18,12 @@ ActivityImpl::~ActivityImpl() XBT_DEBUG("Destroy activity %p", this); } +void ActivityImpl::register_simcall(smx_simcall_t simcall) +{ + simcalls_.push_back(simcall); + simcall->issuer->waiting_synchro = this; +} + void ActivityImpl::clean_action() { if (surf_action_) { diff --git a/src/kernel/activity/ActivityImpl.hpp b/src/kernel/activity/ActivityImpl.hpp index 0d16180e30..d99f965dd2 100644 --- a/src/kernel/activity/ActivityImpl.hpp +++ b/src/kernel/activity/ActivityImpl.hpp @@ -35,6 +35,7 @@ public: virtual void post() = 0; // What to do when a simcall terminates virtual void finish() = 0; + virtual void register_simcall(smx_simcall_t simcall); virtual void clean_action(); virtual double get_remaining() const; // boost::intrusive_ptr support: diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index ae219f6e45..9817117bc7 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -189,8 +189,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, simgrid::kernel::activity: /* Associate this simcall to the wait synchro */ XBT_DEBUG("simcall_HANDLER_comm_wait, %p", comm); - comm->simcalls_.push_back(simcall); - simcall->issuer->waiting_synchro = comm; + comm->register_simcall(simcall); if (MC_is_active() || MC_record_replay_is_active()) { int idx = SIMCALL_GET_MC_VALUE(simcall); diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index a2ca6a8f6e..8e1c3e808a 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -20,8 +20,7 @@ void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::acti XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro, (int)synchro->state_); /* Associate this simcall to the synchro */ - synchro->simcalls_.push_back(simcall); - simcall->issuer->waiting_synchro = synchro; + synchro->register_simcall(simcall); /* set surf's synchro */ if (MC_is_active() || MC_record_replay_is_active()) { diff --git a/src/kernel/activity/IoImpl.cpp b/src/kernel/activity/IoImpl.cpp index 7c23fbb623..db99089236 100644 --- a/src/kernel/activity/IoImpl.cpp +++ b/src/kernel/activity/IoImpl.cpp @@ -18,8 +18,7 @@ void simcall_HANDLER_io_wait(smx_simcall_t simcall, simgrid::kernel::activity::I XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro, (int)synchro->state_); /* Associate this simcall to the synchro */ - synchro->simcalls_.push_back(simcall); - simcall->issuer->waiting_synchro = synchro; + synchro->register_simcall(simcall); /* set surf's synchro */ if (MC_is_active() || MC_record_replay_is_active()) { -- 2.20.1