XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
-void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_activity_t synchro)
+void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro)
{
- XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro.get(), (int)synchro->state_);
+ 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);
/* set surf's synchro */
if (MC_is_active() || MC_record_replay_is_active()) {
synchro->state_ = SIMIX_DONE;
- boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro)->finish();
+ synchro->finish();
return;
}
/* If the synchro is already finished then perform the error handling */
if (synchro->state_ != SIMIX_RUNNING)
- boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro)->finish();
+ synchro->finish();
}
-void simcall_HANDLER_execution_test(smx_simcall_t simcall, smx_activity_t synchro)
+void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro)
{
int res = (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING);
if (res) {
synchro->simcalls_.push_back(simcall);
- boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(synchro)->finish();
+ synchro->finish();
} else {
SIMIX_simcall_answer(simcall);
}
namespace kernel {
namespace activity {
-ExecImpl::ExecImpl(std::string name, std::string tracing_category, resource::Action* timeout_detector, s4u::Host* host)
- : ActivityImpl(std::move(name)), host_(host), timeout_detector_(timeout_detector)
+ExecImpl::ExecImpl(std::string name, std::string tracing_category, s4u::Host* host)
+ : ActivityImpl(std::move(name)), host_(host)
{
this->state_ = SIMIX_RUNNING;
this->set_category(std::move(tracing_category));
- if (timeout_detector != nullptr)
- timeout_detector_->set_data(this);
+ XBT_DEBUG("Create exec %p", this);
+}
+ExecImpl::ExecImpl(std::string name, std::string tracing_category, s4u::Host* host, double timeout)
+ : ExecImpl(std::move(name), std::move(tracing_category), nullptr)
+{
+ if (timeout > 0 && not MC_is_active() && not MC_record_replay_is_active()) {
+ timeout_detector_ = host->pimpl_cpu->sleep(timeout);
+ timeout_detector_->set_data(this);
+ }
XBT_DEBUG("Create exec %p", this);
}
case SIMIX_DONE:
/* do nothing, synchro done */
- XBT_DEBUG("SIMIX_execution_finished: execution successful");
+ XBT_DEBUG("ExecImpl::finish(): execution successful");
break;
case SIMIX_FAILED:
- XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", simcall->issuer->get_host()->get_cname());
+ 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("SIMIX_execution_finished: execution 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("SIMIX_execution_finished: execution timeouted");
+ 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 SIMIX_execution_finish: unexpected synchro state %d", static_cast<int>(state_));
+ xbt_die("Internal error in ExecImpl::finish(): unexpected synchro state %d", static_cast<int>(state_));
}
simcall->issuer->waiting_synchro = nullptr;