X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/96c028707959cb28e44efb23dd23318ec8d29a6c..fb2c3bd152367ef3afaac2cfe3b8c24acdb17982:/src/kernel/activity/ExecImpl.cpp diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 75cf11ecf5..4d9f0234d6 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -23,33 +23,7 @@ void simcall_HANDLER_execution_waitany_for(smx_simcall_t simcall, const std::vector* execs, double timeout) { - if (timeout < 0.0) { - simcall->timeout_cb_ = nullptr; - } else { - simcall->timeout_cb_ = simgrid::simix::Timer::set(SIMIX_get_clock() + timeout, [simcall, execs]() { - simcall->timeout_cb_ = nullptr; - for (auto* exec : *execs) { - // Remove the first occurrence of simcall: - auto j = boost::range::find(exec->simcalls_, simcall); - if (j != exec->simcalls_.end()) - exec->simcalls_.erase(j); - } - simcall_execution_waitany_for__set__result(simcall, -1); - simcall->issuer_->simcall_answer(); - }); - } - - for (auto* exec : *execs) { - /* associate this simcall to the the synchro */ - exec->simcalls_.push_back(simcall); - - /* see if the synchro is already finished */ - if (exec->state_ != simgrid::kernel::activity::State::WAITING && - exec->state_ != simgrid::kernel::activity::State::RUNNING) { - exec->finish(); - break; - } - } + simgrid::kernel::activity::ExecImpl::wait_any_for(simcall->issuer_, execs, timeout); } namespace simgrid { @@ -280,6 +254,37 @@ ActivityImpl* ExecImpl::migrate(s4u::Host* to) return this; } +void ExecImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector* execs, double timeout) +{ + if (timeout < 0.0) { + issuer->simcall_.timeout_cb_ = nullptr; + } else { + issuer->simcall_.timeout_cb_ = simgrid::simix::Timer::set(SIMIX_get_clock() + timeout, [issuer, execs]() { + issuer->simcall_.timeout_cb_ = nullptr; + for (auto* exec : *execs) { + // Remove the first occurrence of simcall: + auto j = boost::range::find(exec->simcalls_, &issuer->simcall_); + if (j != exec->simcalls_.end()) + exec->simcalls_.erase(j); + } + simcall_execution_waitany_for__set__result(&issuer->simcall_, -1); + issuer->simcall_answer(); + }); + } + + for (auto* exec : *execs) { + /* associate this simcall to the the synchro */ + exec->simcalls_.push_back(&issuer->simcall_); + + /* see if the synchro is already finished */ + if (exec->state_ != simgrid::kernel::activity::State::WAITING && + exec->state_ != simgrid::kernel::activity::State::RUNNING) { + exec->finish(); + break; + } + } +} + /************* * Callbacks * *************/