+
+void ExecImpl::finish()
+{
+ while (not simcalls_.empty()) {
+ smx_simcall_t simcall = simcalls_.front();
+ simcalls_.pop_front();
+ switch (state_) {
+
+ case SIMIX_DONE:
+ /* do nothing, synchro done */
+ XBT_DEBUG("ExecImpl::finish(): execution successful");
+ break;
+
+ case SIMIX_FAILED:
+ XBT_DEBUG("ExecImpl::finish(): host '%s' failed", simcall->issuer->get_host()->get_cname());
+ simcall->issuer->context_->iwannadie = true;
+ simcall->issuer->exception_ =
+ std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed"));
+ break;
+
+ case SIMIX_CANCELED:
+ XBT_DEBUG("ExecImpl::finish(): execution canceled");
+ simcall->issuer->exception_ =
+ std::make_exception_ptr(simgrid::CancelException(XBT_THROW_POINT, "Execution Canceled"));
+ break;
+
+ case SIMIX_TIMEOUT:
+ XBT_DEBUG("ExecImpl::finish(): execution timeouted");
+ simcall->issuer->exception_ = std::make_exception_ptr(simgrid::TimeoutError(XBT_THROW_POINT, "Timeouted"));
+ break;
+
+ default:
+ xbt_die("Internal error in ExecImpl::finish(): unexpected synchro state %d", static_cast<int>(state_));
+ }
+
+ simcall->issuer->waiting_synchro = nullptr;
+ simcall_execution_wait__set__result(simcall, state_);
+
+ /* Fail the process if the host is down */
+ if (simcall->issuer->get_host()->is_on())
+ SIMIX_simcall_answer(simcall);
+ else
+ simcall->issuer->context_->iwannadie = true;
+ }
+}
+
+ActivityImpl* ExecImpl::migrate(simgrid::s4u::Host* to)
+{
+ if (not MC_is_active() && not MC_record_replay_is_active()) {
+ resource::Action* old_action = this->surf_action_;
+ resource::Action* new_action = to->pimpl_cpu->execution_start(old_action->get_cost());
+ new_action->set_remains(old_action->get_remains());
+ new_action->set_data(this);
+ new_action->set_priority(old_action->get_priority());
+
+ // FIXME: the user-defined bound seem to not be kept by LMM, that seem to overwrite it for the multi-core modeling.
+ // I hope that the user did not provide any.
+
+ old_action->set_data(nullptr);
+ old_action->cancel();
+ old_action->unref();
+ this->surf_action_ = new_action;
+ }
+
+ on_migration(this, to);
+ return this;
+}
+
+/*************
+ * Callbacks *
+ *************/
+xbt::signal<void(ExecImplPtr)> ExecImpl::on_creation;
+xbt::signal<void(ExecImplPtr)> ExecImpl::on_completion;
+xbt::signal<void(ExecImplPtr, s4u::Host*)> ExecImpl::on_migration;
+
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid